@unifold/connect-react-native 0.1.42 → 0.1.44-beta.1

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.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import*as An from'react';import An__default,{createContext,useContext,useState,useRef,useCallback,useEffect,useMemo,useId,Fragment as Fragment$1}from'react';import {StyleSheet,ScrollView,useWindowDimensions,Platform,PanResponder,Modal,View,Pressable,TouchableOpacity,Text,ActivityIndicator,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Animated,Image,Easing,Dimensions,Clipboard,Linking,FlatList}from'react-native';import Ut,{G,Path,Defs,ClipPath,Rect,LinearGradient,Stop,Circle,Polyline,Line,SvgXml,SvgUri}from'react-native-svg';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {GestureHandlerRootView,TouchableOpacity as TouchableOpacity$1}from'react-native-gesture-handler';import au,{useSharedValue,withSpring,withTiming,runOnJS,useAnimatedStyle,interpolate,Extrapolation}from'react-native-reanimated';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import Wc from'@react-native-async-storage/async-storage';import Gh from'expo-constants';import Fg from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var tu=e=>{throw TypeError(e)};var tf=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var ec=(e,t,r)=>t.has(e)||tu("Cannot "+r);var u=(e,t,r)=>(ec(e,t,"read from private field"),r?r.call(e):t.get(e)),ee=(e,t,r)=>t.has(e)?tu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),A=(e,t,r,o)=>(ec(e,t,"write to private field"),t.set(e,r),r),Ae=(e,t,r)=>(ec(e,t,"access private method"),r);var Ts=(e,t,r,o)=>({set _(n){A(e,t,n);},get _(){return u(e,t,o)}});var tc={light:{background:"#FFFFFF",card:"#F8FAFC",cardHover:"#F1F5F9",foreground:"#0F172A",foregroundMuted:"#64748B",foregroundSubtle:"#94A3B8",border:"#E2E8F0",borderSecondary:"#CBD5E1",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"#DCFCE7",warning:"#F59E0B",warningBackground:"#FEF3C7",error:"#EF4444",errorBackground:"#FEE2E2",overlay:"rgba(0, 0, 0, 0.5)"},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)"}},rc=tc;function ka(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function xs(e,t,r){let o=r?t?.[r]:void 0,n=(c,C,T)=>{let y=o?.[c]?.[C];if(y!==void 0)return y;let b=t?.[c]?.[C];return b!==void 0?b:T},a={backgroundColor:n("card","backgroundColor",e.card),titleColor:n("card","titleColor",e.foreground),subtitleColor:n("card","subtitleColor",e.foregroundMuted),labelColor:n("card","labelColor",e.foregroundMuted),headerColor:n("card","headerColor",e.foregroundMuted),labelRightColor:n("card","labelRightColor",e.foregroundMuted),labelHighlightRightColor:n("card","labelHighlightRightColor",e.warning),textRightColor:n("card","textRightColor",e.foreground),subtextRightColor:n("card","subtextRightColor",e.foregroundMuted),rowLeftLabel:n("card","rowLeftLabel",e.foregroundMuted),rowRightLabel:n("card","rowRightLabel",e.foreground),iconColor:n("card","iconColor",e.primary),iconBackgroundColor:n("card","iconBackgroundColor",e.primary+"26"),actionColor:n("card","actionColor",e.foregroundMuted),actionIcon:n("card","actionIcon",e.foregroundMuted),descriptionColor:n("card","descriptionColor",e.foregroundMuted),borderRadius:n("card","borderRadius",12),borderWidth:n("card","borderWidth",0),borderColor:n("card","borderColor",e.border),shadowColor:n("card","shadowColor","#000"),shadowOffset:n("card","shadowOffset",{width:0,height:-4}),shadowOpacity:n("card","shadowOpacity",0),shadowRadius:n("card","shadowRadius",12),elevation:n("card","elevation",0),iconContainerBorderRadius:n("card","iconContainerBorderRadius",12),backShadowColor:"transparent",backShadowOffset:{top:4,left:4,right:-4,bottom:-4},backShadowSpacing:8},i=(o?.depositMenu??t?.depositMenu)?.card,s=(o?.transferCrypto??t?.transferCrypto)?.depositAddress?.card,l=(o?.depositCard??t?.depositCard)?.quoteProvider?.card,m=(o?.depositTracker??t?.depositTracker)?.executionRow?.card;return {header:{titleColor:n("header","titleColor",e.foreground),buttonColor:n("header","buttonColor",e.foreground)},card:a,input:{backgroundColor:n("input","backgroundColor",n("search","backgroundColor",e.card)),textColor:n("input","textColor",n("search","inputColor",e.foreground)),placeholderColor:n("input","placeholderColor",n("search","placeholderColor",e.foregroundMuted)),borderColor:n("input","borderColor",e.border),borderRadius:n("input","borderRadius",n("search","borderRadius",8)),borderWidth:n("input","borderWidth",1)},button:{primaryBackground:n("button","primaryBackground",e.primary),primaryText:n("button","primaryText",e.primaryForeground),secondaryBackground:n("button","secondaryBackground",e.card),secondaryText:n("button","secondaryText",e.foreground),borderRadius:n("button","borderRadius",12),borderWidth:n("button","borderWidth",0),borderColor:n("button","borderColor",e.border)},container:{titleColor:n("container","titleColor",e.foreground),subtitleColor:n("container","subtitleColor",e.foregroundMuted),actionColor:n("container","actionColor",e.foregroundMuted),actionTitle:n("container","actionTitle",e.foregroundMuted),buttonColor:n("container","buttonColor",e.primary),buttonTitleColor:n("container","buttonTitleColor",e.primaryForeground),iconBackgroundColor:n("container","iconBackgroundColor",e.success),iconColor:n("container","iconColor",e.foreground)},search:{backgroundColor:n("search","backgroundColor",e.card),inputColor:n("search","inputColor",e.foreground),placeholderColor:n("search","placeholderColor",e.foregroundMuted),borderRadius:n("search","borderRadius",8)},list:{titleSectionColor:n("list","titleSectionColor",e.foregroundMuted),rowBorderRadius:n("list","rowBorderRadius",12)},badge:{borderRadius:n("badge","borderRadius",8)},sheet:{shadowColor:n("sheet","shadowColor","#000"),shadowOffset:n("sheet","shadowOffset",{width:0,height:-4}),shadowOpacity:n("sheet","shadowOpacity",.1),shadowRadius:n("sheet","shadowRadius",12),elevation:n("sheet","elevation",16)},depositMenu:{card:ka(a,i)},transferCrypto:{depositAddress:{card:ka(a,s)}},depositCard:{quoteProvider:{card:ka(a,l)}},depositTracker:{executionRow:{card:ka(a,m)}}}}function oc(e,t,r){let n={...tc[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var nc=createContext(null);function F(){let e=useContext(nc);if(!e){let t=rc.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:xs(t,void 0,"dark"),isDark:true}}return e}function kt({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:a,gradientTo:i}){let{colors:s}=F(),l=a??s.warning,m=i??"#FBBF24",c=useRef(new Animated.Value(0)).current,C=useId(),T=useMemo(()=>`circularProgressGrad_${C.replace(/[^a-zA-Z0-9_-]/g,"")}`,[C]),y=(e-t)/2,b=2*Math.PI*y,k=e/2,h=o??Math.max(0,Math.round(e-t*2-8)),p=(e-h)/2;useEffect(()=>{let d=Animated.loop(Animated.timing(c,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return d.start(),()=>d.stop()},[c]);let g=c.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return jsxs(View,{style:[{width:e,height:e},n],children:[jsx(Animated.View,{style:{position:"absolute",top:0,left:0,width:e,height:e,transform:[{rotate:g}]},children:jsxs(Ut,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:T,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:l}),jsx(Stop,{offset:"100%",stopColor:m})]})}),jsx(Circle,{cx:k,cy:k,r:y,stroke:`url(#${T})`,strokeWidth:t,fill:"none",strokeDasharray:`${b*.75} ${b*.25}`,strokeLinecap:"round",rotation:-90,origin:`${k}, ${k}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:p+1.5,left:p,width:h,height:h},children:r}):null]})}function ac({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Pi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function zr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _s({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function st({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"18",y1:"6",x2:"6",y2:"18",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Tr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Fi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"15 18 9 12 15 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Bt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function No({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{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:t,strokeWidth:r,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:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function $e({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Rs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12.01",y2:"16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function lc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"2",x2:"12",y2:"6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"18",x2:"12",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"12",x2:"6",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"18",y1:"12",x2:"22",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ko({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function gn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function xa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function To({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function _a({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Oi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function yn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ra({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Is({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M5.43 5.43A8.06 8.06 0 0 0 4 10c0 6 8 12 8 12a29.94 29.94 0 0 0 5-5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M19.18 13.52A8.66 8.66 0 0 0 20 10a8 8 0 0 0-8-8 7.88 7.88 0 0 0-3.52.82",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9.13 9.13A2.78 2.78 0 0 0 9 10a3 3 0 0 0 3 3 2.78 2.78 0 0 0 .87-.13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function iu({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Ut,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M11 14h10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 10l4 4-4 4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Di({children:e,mode:t="auto",accentColor:r,theme:o,fontFamily:n,fonts:a,components:i}){let s=useColorScheme(),l=useMemo(()=>t==="auto"?s==="dark"?"dark":"light":t,[t,s]),m=useMemo(()=>{let y=o?.[l];return oc(l,y,r)},[l,o,r]),c=useMemo(()=>xs(m,i,l),[m,i,l]),C=useMemo(()=>a?{regular:a.regular||n,medium:a.medium||n,semibold:a.semibold||n,bold:a.bold||n}:n?{regular:n,medium:n,semibold:n,bold:n}:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},[n,a]),T=useMemo(()=>({mode:l,colors:m,fonts:C,components:c,isDark:l==="dark"}),[l,m,C,c]);return jsx(nc.Provider,{value:T,children:e})}var Os={damping:28,stiffness:300,mass:.8},Df=80,Vf=500;function ft({visible:e,onClose:t,children:r,closeOnBackdropPress:o=true,enablePanDownToClose:n=true,showHandle:a=true,heightPercent:i,maxHeightPercent:s,startExpanded:l=false,noPadding:m=false,borderTopLeftRadius:c=24,borderTopRightRadius:C=24}){let{colors:T}=F(),{height:y}=useWindowDimensions(),[b,k]=useState(false),h=useRef(e);h.current=e;let p=useRef(0),g=i!=null&&i>=1,d=g||m?0:Platform.OS==="ios"?34:24,f=s!=null&&i!=null&&s>i,_=i!=null?(f?s:i)*y:void 0,R=f?(s-i)*y:0,w=l?0:R,S=useSharedValue(y),x=useRef(null),W=useCallback(()=>{x.current&&(clearTimeout(x.current),x.current=null),h.current||k(false);},[]);useEffect(()=>{e?(x.current&&(clearTimeout(x.current),x.current=null),k(true),S.value=withSpring(w,Os)):b&&(S.value=withTiming(y,{duration:250},q=>{q&&runOnJS(W)();}),x.current=setTimeout(()=>{x.current=null,W();},350));},[e]),useEffect(()=>()=>{x.current&&clearTimeout(x.current);},[]),useEffect(()=>{b&&e&&(S.value=withSpring(w,Os));},[w]);let D=useCallback(()=>{o&&t();},[o,t]),O=useMemo(()=>{if(!(!n&&!f))return PanResponder.create({onStartShouldSetPanResponder:()=>true,onMoveShouldSetPanResponder:()=>true,onPanResponderGrant:()=>{p.current=S.value;},onPanResponderMove:(q,ae)=>{if(Math.abs(ae.dy)<4)return;let Me=p.current+ae.dy;S.value=Math.max(0,Me);},onPanResponderRelease:(q,ae)=>{if(!(Math.abs(ae.dy)<4)){if(n&&(ae.dy>Df||ae.vy>Vf)){t();return}if(f){let Me=R/2,Oe=S.value<Me?0:R;S.value=withSpring(Oe,Os);}else S.value=withSpring(w,Os);}},onPanResponderTerminate:()=>{S.value=withSpring(w,Os);}}).panHandlers},[n,f,R,w,S,t]),P=useAnimatedStyle(()=>({transform:[{translateY:S.value}]})),j=useAnimatedStyle(()=>({opacity:interpolate(S.value,[0,y*.5,y],[.5,.25,0],Extrapolation.CLAMP)}));return b?jsx(Modal,{transparent:true,visible:true,animationType:"none",onRequestClose:t,children:jsxs(View,{style:Kn.root,pointerEvents:e?"auto":"none",children:[jsx(au.View,{style:[Kn.backdrop,j],pointerEvents:e?"auto":"none",children:jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:D})}),jsxs(au.View,{style:[Kn.sheet,P,{height:_,backgroundColor:T.background,borderTopLeftRadius:g?0:c,borderTopRightRadius:g?0:C}],children:[jsxs(GestureHandlerRootView,{style:Kn.gestureRoot,children:[a&&jsx(View,{style:Kn.handleContainer,pointerEvents:"none",children:jsx(View,{style:[Kn.handle,{backgroundColor:T.foreground+"33"}]})}),r,d>0&&jsx(View,{style:{height:d}})]}),O&&jsx(View,{...O,style:Kn.dragOverlay})]})]})}):null}var Kn=StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject,backgroundColor:"#000"},sheet:{overflow:"hidden"},gestureRoot:{flex:1},handleContainer:{alignItems:"center",paddingTop:10,paddingBottom:4,zIndex:1},dragOverlay:{position:"absolute",top:0,left:0,right:0,height:40,zIndex:2},handle:{width:36,height:5,borderRadius:2.5}}),ht=An__default.forwardRef((e,t)=>jsx(ScrollView,{ref:t,...e}));ht.displayName="BottomSheetScrollView";function Vi(e){return jsx(FlatList,{...e})}var Lf="https://api.unifold.io",mc="__UnifoldDevApiBaseUrl__",xr="pk_test_123",Ia={};function Bf(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[mc];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function er(){return Bf()??Lf}function va(e){if(e.publishableKey!==void 0){if(!e.publishableKey||e.publishableKey.trim()==="")throw new Error("Unifold SDK: publishableKey cannot be empty. Please provide a valid publishable key.");!e.publishableKey.startsWith("pk_test_")&&!e.publishableKey.startsWith("pk_live_")&&console.warn('Unifold SDK: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),xr=e.publishableKey;}e.defaultConfig&&(Ia=e.defaultConfig);}function cu(e){if(typeof __DEV__>"u"||!__DEV__){console.warn("[Unifold] setDevApiUrl() is only available in development mode");return}if(typeof globalThis>"u")return;let t=e.trim();t.length>0?globalThis[mc]=t:delete globalThis[mc];}function Ds(){return er()}function Pa(){return xr}function Ur(e){if(!e||e.trim()==="")throw new Error("Unifold SDK: No publishable key configured. Please provide a valid publishable key via setApiConfig() or pass it directly to the API function.");e==="pk_test_123"&&console.warn('Unifold SDK: Using default test key "pk_test_123". This should only be used for local development. Please use a real publishable key in production.');}function Gt(e){let t=e.startsWith("/")?e:`/${e}`;return `${er()}/api/public${t}`}function re(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,er()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${er()}${e}`:`${er()}/api/public${e}`:""}async function $o(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||Ia.recipientAddress;if(!r)throw new Error("[Unifold] recipient_address is required for createDepositAddress. Pass recipientAddress in your beginDeposit() config.");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||Ia.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Ia.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||xr;Ur(n);let a=await fetch(`${er()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok)throw new Error(`Failed to create deposit address: ${a.statusText}`);return await a.json()}function qo(e,t){return e.find(r=>r.chain_type===t)}async function Qo(e,t,r){let o=t||xr;Ur(o);let n=await fetch(`${er()}/v1/public/direct_executions/query`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify({external_user_id:e,...r&&{action_type:r}})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}async function Fa(e,t){let r=t||xr;Ur(r);let o=await fetch(`${er()}/v1/public/direct_executions/poll`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify({deposit_wallet_id:e})});if(!o.ok)throw new Error(`Failed to poll executions: ${o.statusText}`);return o.json()}function Se(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let r=e.icon_urls.find(o=>o.format===t);return r?r.url:e.icon_url}async function Gn(e,t){let r=e||xr;Ur(r);let o=`${er()}/v1/public/tokens/supported_deposit_tokens`;if(t?.destination_token_address&&t?.destination_chain_id&&t?.destination_chain_type){let a=new URLSearchParams({destination_token_address:t.destination_token_address,destination_chain_id:t.destination_chain_id,destination_chain_type:t.destination_chain_type});o=`${o}?${a.toString()}`;}let n=await fetch(o,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch supported deposit tokens: ${n.statusText}`);return n.json()}async function fc(e,t){let r=t||xr;Ur(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${er()}/v1/public/tokens/token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch token metadata: ${n.statusText}`);return n.json()}function Oa(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function hc(e,t){let r=t||xr;Ur(r);let o=await fetch(`${er()}/v1/public/onramps/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to fetch onramp quotes: ${o.statusText}`);return o.json()}async function gc(e,t){let r=t||xr;Ur(r);let o=await fetch(`${er()}/v1/public/onramps/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to create onramp session: ${o.statusText}`);return o.json()}async function yc(e,t){let r=t||xr;Ur(r);let o=new URLSearchParams;e.country_code&&o.append("country_code",e.country_code),e.subdivision_code&&o.append("subdivision_code",e.subdivision_code),o.append("token_address",e.token_address),o.append("chain_id",e.chain_id),o.append("chain_type",e.chain_type);let n=await fetch(`${er()}/v1/public/onramps/default_token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch default onramp token: ${n.statusText}`);return n.json()}async function bc(e){let t=e||xr;Ur(t);let r=await fetch(`${er()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch fiat currencies: ${r.statusText}`);return r.json()}function Li(e,t="png"){if(!e||e.length===0)return;let r=e.find(o=>o.format===t);return r?r.url:e[0]?.url}async function Vs(e){let t=e||xr;Ur(t);let r=await fetch(`${er()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch project config: ${r.statusText}`);return r.json()}async function Cc(){let e=await fetch(`${er()}/v1/public/tokens/chains`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch token chains: ${e.statusText}`);return e.json()}function Da(e,t,r){let o=e.find(a=>a.chain_id===r);if(o)return o.chain_name;let n=e.find(a=>a.chain_type===t);return n?n.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}async function Ls(){let e=await fetch(`${er()}/v1/public/ip_address`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch IP address information: ${e.statusText}`);return e.json()}async function Va(e){let t=e||xr;Ur(t);let r=await fetch(`${er()}/v1/public/tokens/supported_destination_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch supported destination tokens: ${r.statusText}`);return r.json()}async function wc(e,t){let r=t||xr;Ur(r);let o=await fetch(`${er()}/v1/public/addresses/verify`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":r},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to verify address: ${o.statusText}`);return o.json()}async function Sc(e,t){return Fa(e.deposit_wallet_id,t)}async function La(e,t,r,o,n){let a=n||xr;Ur(a);let i=await fetch(`${er()}/v1/public/addresses/balance`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":a},body:JSON.stringify({address:e,chain_type:t,chain_id:r,token_address:o})});if(!i.ok)throw new Error(`Failed to fetch address balance: ${i.statusText}`);return i.json()}function uu({size:e=28}){return jsx(Ut,{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 mu({size:e=28}){return jsxs(Ut,{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 gu({size:e=28}){return jsxs(Ut,{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 yu({size:e=28}){return jsxs(Ut,{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 bu({size:e=28}){return jsx(Ut,{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 Ba=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:uu},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:mu},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:gu},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:yu},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:bu}];function Aa(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function Wa(e,t){let r=parseFloat(e);if(isNaN(r))return e;let o=t.toLowerCase(),n=["eth","btc"].includes(o)?4:2;return r.toFixed(n)}function Wi(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=Ba.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=Ba.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function Yt({onPress:e,title:t,variant:r="close",leftAction:o}){let{components:n,fonts:a}=F(),i=r==="back",s=i?jsx(Fi,{size:22,color:n.header.buttonColor,strokeWidth:2.5}):jsx(st,{size:20,color:n.header.buttonColor,strokeWidth:2}),l=jsx(TouchableOpacity,{style:bn.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:i?"Back":"Close",children:s});return t?jsxs(View,{style:bn.headerWithTitle,children:[i?l:o??jsx(View,{style:bn.headerSide}),jsx(Text,{style:[bn.headerTitleText,{color:n.header.titleColor},...a.bold?[{fontFamily:a.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),i?jsx(View,{style:bn.headerSide}):l]}):jsxs(View,{style:i?bn.headerWithTitle:bn.header,children:[i?l:jsx(View,{style:bn.headerSpacer}),!i&&l]})}var Ea={paddingTop:8,paddingBottom:8},bn=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Ea},headerWithTitle:{flexDirection:"row",alignItems:"center",...Ea},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 _r({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=F();return e?jsx(Text,{style:[Cu.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[Cu.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var Cu=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function fo({quote:e,label:t,value:r,last:o,hideDivider:n}){return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsx(Text,{style:[e.rowValue],children:r})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}function Ic({quote:e,label:t,address:r,last:o,hideDivider:n}){let[a,i]=useState(false),{colors:s,components:l}=F(),m=()=>{Clipboard.setString(r),i(true),setTimeout(()=>i(false),2e3);},c=Aa(r);return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsxs(View,{style:e.rowRight,children:[jsx(Text,{style:[e.rowValue,{flexShrink:1,minWidth:0}],numberOfLines:1,ellipsizeMode:"middle",selectable:true,children:c}),jsx(TouchableOpacity,{onPress:m,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:a?jsx($e,{size:14,color:s.success,strokeWidth:2.5}):jsx(No,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var Ma={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function Es({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=F(),a=e.toLowerCase(),i=Ma[a]??n.primary,s=Math.round(o*.42);return jsxs(View,{style:{width:o,height:o,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:o,height:o,borderRadius:o/2}}):jsx(View,{style:{width:o,height:o,borderRadius:o/2,backgroundColor:i,alignItems:"center",justifyContent:"center"},children:jsx(Text,{style:{color:"#FFFFFF",fontWeight:"700",fontSize:o*.38},children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),r?jsx(Image,{source:{uri:r},style:{position:"absolute",bottom:-2,right:-4,width:s,height:s,borderRadius:s/2,borderWidth:2,borderColor:n.background}}):null]})}function za({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:a}){let{colors:i,components:s,fonts:l}=F(),m=Gt(`/icons/currencies/png/${e.toLowerCase()}.png`),c=Wi(r);return jsxs(View,{style:[eo.diagram,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor},a],children:[jsxs(View,{style:eo.step,children:[jsx(Image,{source:{uri:m},style:eo.iconImage}),jsx(Text,{style:[eo.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You paid"}),jsx(Text,{style:[eo.value,{color:s.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(Tr,{size:16,color:i.foregroundMuted,strokeWidth:2}),jsxs(View,{style:eo.step,children:[jsxs(View,{style:eo.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:eo.tokenIcon}):jsx(View,{style:[eo.tokenIcon,{backgroundColor:Ma[t.toLowerCase()]??i.primary}]}),n?jsx(Image,{source:{uri:n},style:[eo.networkBadge,{borderColor:i.background}]}):null]}),jsx(Text,{style:[eo.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[eo.value,{color:s.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",c]})]})]})}var eo=StyleSheet.create({diagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",paddingVertical:20,paddingHorizontal:24,width:"100%"},step:{alignItems:"center"},iconImage:{width:24,height:24,borderRadius:12,marginBottom:4},iconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},tokenIcon:{width:24,height:24,borderRadius:12},networkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderRadius:7,borderWidth:2},label:{fontSize:10},value:{fontSize:14,fontWeight:"500",paddingTop:4}});function Ei(){let{colors:e,fonts:t,components:r}=F(),o=r.input,n=r.button,a=r.container,i=r.card,s=r.header;return useMemo(()=>{let l=i.borderRadius,m={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:16},content:{flex:1,paddingTop:16},title:{fontSize:28,color:s.titleColor,marginBottom:8,...t.bold?{fontFamily:t.bold}:{}},subtitle:{fontSize:15,color:e.foregroundMuted,marginBottom:36,lineHeight:22,...t.regular?{fontFamily:t.regular}:{}},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:13,color:e.foregroundSubtle,marginBottom:8,textTransform:"uppercase",letterSpacing:.5,...t.semibold?{fontFamily:t.semibold}:{}},input:{backgroundColor:o.backgroundColor,borderRadius:o.borderRadius,padding:16,fontSize:17,color:o.textColor,borderWidth:o.borderWidth,borderColor:o.borderColor,...t.regular?{fontFamily:t.regular}:{}},hint:{fontSize:12,color:e.foregroundSubtle,marginTop:8,...t.regular?{fontFamily:t.regular}:{}},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:e.card,paddingHorizontal:14,paddingVertical:10,borderRadius:Math.min(l,12)},emailLabel:{fontSize:13,color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},emailValue:{fontSize:13,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},footer:{gap:4},continueBtn:{backgroundColor:a.buttonColor,borderRadius:n.borderRadius,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:e.card},continueBtnText:{color:a.buttonTitleColor,fontSize:17,...t.bold?{fontFamily:t.bold}:{}},continueBtnTextDisabled:{color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:e.foregroundMuted,fontSize:15,...t.medium?{fontFamily:t.medium}:{}},loaderInButton:{justifyContent:"center",alignItems:"center"}},c={amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,color:e.foreground,letterSpacing:-2,minWidth:80,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},amountPlaceholder:{color:e.foregroundSubtle},currencyLabel:{fontSize:15,color:e.foregroundMuted,letterSpacing:1,...t.medium?{fontFamily:t.medium}:{}},quickRow:{flexDirection:"row",gap:10,marginBottom:12},quickPill:{flex:1,paddingVertical:12,alignItems:"center",borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor},quickPillText:{fontSize:14,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},numpad:{gap:4,marginBottom:12},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:56,alignItems:"center",justifyContent:"center",marginHorizontal:4},numpadKeyText:{fontSize:28,color:e.foreground,...t.regular?{fontFamily:t.regular}:{}},backspaceText:{fontSize:22,color:e.foregroundMuted,...t.regular?{fontFamily:t.regular}:{}},paymentRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,borderRadius:999,backgroundColor:"transparent",alignSelf:"flex-start",marginBottom:12},paymentRowHeader:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:16,borderRadius:i.borderRadius,backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:i.borderColor,alignSelf:"center"},paymentLeft:{flexDirection:"row",alignItems:"center",gap:6},applePayIcon:{fontSize:20,color:e.foreground},paymentLabel:{fontSize:15,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},paymentHint:{fontSize:13,color:e.foregroundMuted,marginLeft:12,...t.regular?{fontFamily:t.regular}:{}},inlineError:{fontSize:13,color:e.error,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},inlineStatus:{fontSize:13,color:e.foregroundMuted,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},sheetContent:{flex:1,paddingHorizontal:24,paddingTop:8,paddingBottom:32,gap:12},sheetHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:4},sheetBackBtn:{width:32,height:32,borderRadius:16,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitleRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},sheetCloseBtn:{width:28,height:28,borderRadius:14,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:i.borderWidth,borderColor:e.border},sheetTitle:{fontSize:18,color:e.foreground,...t.bold?{fontFamily:t.bold}:{}},sheetOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border},sheetOptionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:12},sheetOptionIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},sheetOptionLabel:{fontSize:16,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},sheetOptionHint:{fontSize:13,color:e.foregroundMuted,marginTop:2,...t.regular?{fontFamily:t.regular}:{}},sheetLoading:{alignItems:"center",paddingVertical:32,gap:12},sheetStatusText:{fontSize:15,color:e.foregroundMuted,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},sheetError:{flex:1,justifyContent:"center",paddingVertical:20},sheetErrorText:{fontSize:14,color:e.error,textAlign:"center",lineHeight:20,...t.regular?{fontFamily:t.regular}:{}},addPaymentBtn:{marginTop:12,paddingVertical:14,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center"},addPaymentBtnText:{fontSize:15,color:e.primary,...t.semibold?{fontFamily:t.semibold}:{}}},C={heroBox:{backgroundColor:i.backgroundColor,borderRadius:l,padding:24,alignItems:"center",marginBottom:16,marginTop:8,borderWidth:i.borderWidth,borderColor:i.borderColor,gap:4},heroLabel:{fontSize:12,color:e.foregroundSubtle,letterSpacing:.5,textTransform:"uppercase",...t.semibold?{fontFamily:t.semibold}:{}},heroAmount:{fontSize:48,color:e.foreground,letterSpacing:-1,...t.bold?{fontFamily:t.bold}:{}},heroCurrency:{fontSize:22,color:e.primary,...t.medium?{fontFamily:t.medium}:{}},heroNetwork:{fontSize:15,color:e.foregroundSubtle,marginTop:2,...t.medium?{fontFamily:t.medium}:{}},card:{backgroundColor:i.backgroundColor,borderRadius:l,borderWidth:i.borderWidth,borderColor:i.borderColor,overflow:"hidden",marginBottom:12,marginTop:16},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:i.rowLeftLabel,...t.regular?{fontFamily:t.regular}:{}},rowValue:{fontSize:14,fontWeight:"500",color:i.rowRightLabel,...t.medium?{fontFamily:t.medium}:{}}},T=Math.max(16,Math.min(l,22)),y={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,paddingHorizontal:16,paddingVertical:16},swapCardTop:{borderTopLeftRadius:T,borderTopRightRadius:T,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:T,borderBottomRightRadius:T,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,...t.regular?{fontFamily:t.regular}:{}},swapReceivePrimary:{fontSize:40,color:e.foreground,letterSpacing:-1,...t.regular?{fontFamily:t.regular}:{}},swapReceiveSub:{fontSize:13,color:e.foregroundMuted,marginTop:4,...t.regular?{fontFamily:t.regular}:{}},swapPill:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:10,paddingHorizontal:14,borderRadius:999,backgroundColor:e.cardHover,borderWidth:i.borderWidth,borderColor:e.border},swapPillText:{fontSize:16,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},payHint:{fontSize:15,color:e.foregroundMuted,textAlign:"center",marginBottom:18,marginTop:4,...t.regular?{fontFamily:t.regular}:{}},summaryLabel:{fontSize:12,color:e.foregroundSubtle,textTransform:"uppercase",letterSpacing:.3,...t.semibold?{fontFamily:t.semibold}:{}},applePayBtn:{backgroundColor:n.secondaryBackground,borderRadius:n.borderRadius,borderWidth:n.borderWidth>0?n.borderWidth:1,borderColor:n.borderWidth>0?n.borderColor:e.border,paddingVertical:18,alignItems:"center",marginBottom:10},applePayBtnText:{color:n.secondaryText,fontSize:17,...t.bold?{fontFamily:t.bold}:{}}},b={input:{fontSize:14,...t.regular?{fontFamily:t.regular}:{}},list:{gap:8},row:{flexDirection:"row",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(l,14),borderWidth:i.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,...t.medium?{fontFamily:t.medium}:{}},rowTextSelected:{color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},checkCircle:{width:24,height:24,borderRadius:12,backgroundColor:e.primary,alignItems:"center",justifyContent:"center"}},k={centered:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24},spinnerWrap:{width:80,height:80,borderRadius:40,backgroundColor:e.card,borderWidth:i.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:s.titleColor,textAlign:"center",marginBottom:10,...t.bold?{fontFamily:t.bold}:{}},sub:{fontSize:15,color:e.foregroundMuted,textAlign:"center",lineHeight:22,marginBottom:36,...t.regular?{fontFamily:t.regular}:{}},successScrollContent:{flexGrow:1,width:"100%",alignItems:"center",paddingBottom:24},detailCard:{width:"100%"}};return {form:m,quote:C,pm:y,wallet:b,flow:k,amount:c}},[e,t,o,n,a,i,s])}var ku="",Tu;function Ua(e){ku=e;}function Ha(e){Tu=e;}function Dr(){let e=ku||Pa();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function Vr(){return Tu??Ds()}async function Na(){let e=`${Vr()}/v1/public/onramps/headless/stripe/config`,t=Dr(),r=await fetch(e,{method:"GET",headers:{"x-publishable-key":t,"Content-Type":"application/json"}});if(!r.ok)throw new Error(`Failed to load Stripe config: ${r.status}`);let o=await r.json();if(!o?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return o.publishable_key}async function vc(e){let t=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok)throw new Error(`Failed to create auth intent: ${t.status}`);let r=await t.json();return r.auth_intent_id??r.id}async function xu(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e,...t&&{crypto_customer_id:t}})});if(!r.ok)throw new Error(`Failed to exchange auth intent for tokens: ${r.status}`);return r.json()}async function Pc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e,...t&&{crypto_customer_id:t}})}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o?.message??`Failed to refresh OAuth token: ${r.status}`);return o}async function _u(e,t){let r={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},o=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t,"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await o.text();if(!o.ok)throw new Error(`Failed to create onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function Ru(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}}),o=await r.text();if(!r.ok)throw new Error(`Failed to confirm onramp session: ${r.status} ${o}`);return JSON.parse(o)}async function ja(e,t){let r=`${Vr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp customer: ${o.status} ${n}`);return JSON.parse(n)}async function Iu(e){let t=`${Vr()}/v1/public/onramps/headless/stripe/sessions`,r=await fetch(t,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":e}}),o=await r.text();if(!r.ok)throw new Error(`Failed to list onramp sessions: ${r.status} ${o}`);return JSON.parse(o)}async function vu(e,t){let r=`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function Fc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}});if(!r.ok){let o=await r.text();throw new Error(`Failed to refresh quote: ${r.status} ${o}`)}return r.json()}async function Pu(e){let t=new URLSearchParams({destinationNetwork:e.destinationNetwork,walletAddress:e.walletAddress});e.destinationTag&&t.set("destinationTag",e.destinationTag),e.cryptoCustomerId&&t.set("crypto_customer_id",e.cryptoCustomerId);let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":e.accessToken}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch transaction limits: ${r.status} ${o}`)}return r.json()}async function Oc(e,t){let r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":Dr(),"x-stripe-oauth-token":t}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch payment tokens: ${r.status} ${o}`)}return r.json()}async function Fu(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let t={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:{}},r=await fetch(`${Vr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":Dr(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create deposit address: ${r.status}`);return r.json()}function Cn(e,t){if(e?.length){let r=e.find(n=>n.format==="png");if(r)return r.url;let o=e.find(n=>n.format==="svg");if(o)return o.url}return t}async function Ou(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${Vr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":Dr()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}function lh({size:e=24}){let t=e,r=e*(471/750);return jsxs(Ut,{width:t,height:r,viewBox:"0 0 750 471",children:[jsx(Rect,{width:"750",height:"471",rx:"40",fill:"#1A1F71"}),jsx(Path,{fill:"#FFFFFF",d:"M278.198,334.228l33.36-195.763h53.358l-33.384,195.763H278.198z"}),jsx(Path,{fill:"#FFFFFF",d:"M524.307,142.687c-10.57-3.966-27.135-8.222-47.822-8.222c-52.725,0-89.863,26.551-90.18,64.604c-0.297,28.129,26.514,43.821,46.754,53.185c20.77,9.597,27.752,15.716,27.652,24.283c-0.133,13.123-16.586,19.116-31.924,19.116c-21.355,0-32.701-2.967-50.225-10.274l-6.877-3.112l-7.488,43.823c12.463,5.466,35.508,10.199,59.438,10.445c56.09,0,92.502-26.248,92.916-66.884c0.199-22.27-14.016-39.216-44.801-53.188c-18.65-9.056-30.072-15.099-29.951-24.269c0-8.137,9.668-16.838,30.559-16.838c17.447-0.271,30.088,3.534,39.936,7.5l4.781,2.259L524.307,142.687"}),jsx(Path,{fill:"#FFFFFF",d:"M661.615,138.464h-41.23c-12.773,0-22.332,3.486-27.941,16.234l-79.244,179.402h56.031c0,0,9.16-24.121,11.232-29.418c6.123,0,60.555,0.084,68.336,0.084c1.596,6.854,6.492,29.334,6.492,29.334h49.512L661.615,138.464z M596.198,264.872c4.414-11.279,21.26-54.724,21.26-54.724c-0.314,0.521,4.381-11.334,7.074-18.684l3.607,16.878c0,0,10.217,46.729,12.352,56.527h-44.293V264.872z"}),jsx(Path,{fill:"#FFFFFF",d:"M45.879,138.465l-0.682,4.073c21.093,5.106,39.932,12.496,56.426,21.689l47.346,169.688h56.455l83.004-195.45h-56.526l-52.238,133.496l-5.564-27.131c-0.261-0.838-0.544-1.678-0.834-2.52L156.106,154.992c-3.229-12.396-12.597-16.095-24.186-16.528H45.879z"})]})}function ch({size:e=24}){return jsx(Ut,{width:e,height:e,viewBox:"0 0 24 24",children:jsxs(G,{fill:"none",fillRule:"evenodd",children:[jsx(Circle,{cx:"7",cy:"12",r:"7",fill:"#EA001B"}),jsx(Circle,{cx:"17",cy:"12",r:"7",fill:"#FFA200",fillOpacity:.8})]})})}function dh({size:e=24}){return jsx(Ut,{width:e,height:e,viewBox:"0 0 1152 1152",children:jsxs(G,{transform:"matrix(1.3333333,0,0,-1.3333333,0,1152)",children:[jsx(Path,{fill:"#006FCF",d:"M 0,0 H 863.998 V 864 H 0 Z"}),jsx(G,{transform:"translate(312.9867,136.7145)",children:jsx(Path,{fill:"#FFFFFF",d:"m 0,0 341.634,-0.725 53.654,59.858 54.038,-59.632 h 101.685 v 87.332 l -63.687,68.682 63.687,68.059 V 309.09 L 0,309.585 Z"})}),jsx(G,{transform:"translate(349.7917,170.655)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"m 0,0 v 241.575 h 204.832 v -55.65 H 66.318 V 148.15 H 201.529 V 93.423 H 66.318 V 56.319 H 204.832 V 10e-4 Z"})}),jsx(G,{transform:"translate(780.0408,412.227)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 -69.456,-76.568 -138.713,0 h -87.729 l 113.343,-120.647 -113.341,-120.925 h 85.343 l 69.764,77.335 70.487,-77.335 h 84.803 v 3.43 L -26.971,-120.647 83.957,-1.903 V 0 Z"})}),jsx(G,{transform:"translate(738.7857,721.0845)",children:jsx(Path,{fill:"#FFFFFF",d:"M 0,0 -28.373,-79.366 -56.65,0 H -220.625 V -105.93 L -267.278,0 H -400.1 l -136.414,-309.586 h 661.726 l 0,309.586 z"})}),jsx(G,{transform:"translate(373.0462,548.583)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"M 0,0 32.145,76.837 64.268,0 Z m -9.212,138.867 -107.187,-241.37 h 73.518 l 20.22,48.332 H 86.914 l 20.207,-48.332 h 75.345 L 75.723,138.867 Z"})}),jsx(G,{transform:"translate(554.5071,446.121)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 64.997,-0.001 V 165.796 L 126.661,-0.001 h 58.418 L 245.49,165.233 V -0.564 l 64,0.563 V 241.368 H 210.032 L 156.513,92.624 103.342,241.012 0,241.369 Z"})})]})})}function Vc({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(Pi,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(lh,{size:t}):o.includes("mastercard")?jsx(ch,{size:t}):o.includes("amex")||o.includes("american express")?jsx(dh,{size:t}):jsx(Pi,{size:t*.75,color:r,strokeWidth:1.75})}var mh=[50,100,500],fh=[["1","2","3"],["4","5","6"],["7","8","9"],[".","0","\u232B"]];function Bu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function hh(e){return e.card?`${Bu(e.card.brand)} ${Bu(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Wu(e){if(!e)return "";let t=new Date(e*1e3);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true})}var Eu={initialized:"Initialized",requires_payment:"Awaiting Payment",fulfillment_processing:"Processing",fulfillment_complete:"Complete",rejected:"Rejected"};function Mu(e,t){switch(e){case "fulfillment_complete":return t.success;case "fulfillment_processing":case "requires_payment":return t.warning;case "rejected":return t.error;default:return t.foregroundMuted}}function gh({status:e,colors:t,fontFamily:r}){let o=Mu(e,t);return jsx(View,{style:{paddingHorizontal:8,paddingVertical:2,borderRadius:6,backgroundColor:o+"20"},children:jsx(Text,{style:{fontSize:11,color:o,fontFamily:r},children:Eu[e]??e})})}function yh({session:e,onBack:t}){let{colors:r,components:o,fonts:n}=F(),[a,i]=useState(false),s=()=>{Clipboard.setString(e.id),i(true),setTimeout(()=>i(false),2e3);},l=e.transaction_details,m=e.status!=="fulfillment_complete"&&e.status!=="rejected",c=Mu(e.status,r),C=l?.source_amount?`$${parseFloat(l.source_amount).toFixed(2)}`:"\u2014",T=l?.destination_amount?parseFloat(l.destination_amount).toFixed(2):"\u2014",y=(l?.destination_currency??"").toUpperCase(),b=e.destination_token_metadata,k=Cn(b?.icon_urls,b?.icon_url),h=Cn(b?.chain?.icon_urls,b?.chain?.icon_url),p=Wi(l?.destination_network??""),g=l?.wallet_address?Aa(l.wallet_address):null,d=l?.fees?.network_fee_amount?`$${parseFloat(l.fees.network_fee_amount).toFixed(2)}`:null,f=l?.fees?.transaction_fee_amount?`$${parseFloat(l.fees.transaction_fee_amount).toFixed(2)}`:null,_=e.payment_method?e.payment_method.replace(/_/g," ").replace(/\b\w/g,w=>w.toUpperCase()):null,R=[{label:"Amount",value:C},{label:"Received",value:`${T} ${y}`},..._?[{label:"Payment",value:_}]:[],{label:"Network",value:p},...g?[{label:"Wallet",value:g}]:[],...d?[{label:"Network Fee",value:d}]:[],...f?[{label:"Transaction Fee",value:f}]:[]];return jsxs(Fragment,{children:[jsx(View,{style:{paddingLeft:16,paddingTop:8},children:jsx(Yt,{onPress:t,title:"Purchase Details",variant:"back"})}),jsxs(ht,{style:tr.scroll,contentContainerStyle:tr.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:tr.iconSection,children:[jsxs(View,{style:{marginBottom:12,width:64,height:64},children:[jsx(Es,{currency:y||"USD",tokenIconUrl:k,networkIconUrl:h,size:64}),jsx(View,{style:[tr.statusBadge,{backgroundColor:c,borderColor:o.card.backgroundColor??r.background}],children:m?jsx(zr,{size:14,color:"#FFFFFF",strokeWidth:2.5}):e.status==="rejected"?jsx(st,{size:14,color:"#FFFFFF",strokeWidth:2.5}):jsx($e,{size:14,color:"#FFFFFF",strokeWidth:2.5})})]}),jsxs(View,{style:tr.statusRow,children:[jsx(View,{style:[tr.statusDot,{backgroundColor:c}]}),jsx(Text,{style:[tr.statusText,{color:o.container.titleColor,fontFamily:n.semibold}],children:Eu[e.status]??e.status})]}),e.created?jsx(Text,{style:[tr.dateText,{color:o.container.subtitleColor,fontFamily:n.regular}],children:Wu(e.created)}):null]}),jsxs(View,{style:[tr.card,{backgroundColor:o.card.backgroundColor,borderRadius:o.card.borderRadius,borderWidth:o.card.borderWidth,borderColor:o.card.borderColor}],children:[jsxs(View,{style:tr.cardRow,children:[jsx(Text,{style:[tr.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:"ID"}),jsxs(TouchableOpacity$1,{onPress:s,activeOpacity:.7,style:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},children:[jsx(Text,{style:[tr.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium,fontSize:12}],numberOfLines:1,children:e.id.length>12?e.id.slice(0,12)+"\u2026":e.id}),a?jsx($e,{size:14,color:r.primary,strokeWidth:2}):jsx(No,{size:14,color:r.foregroundMuted,strokeWidth:2})]})]}),R.map((w,S)=>jsxs(An__default.Fragment,{children:[jsx(View,{style:[tr.cardDivider,{backgroundColor:r.border}]}),jsxs(View,{style:tr.cardRow,children:[jsx(Text,{style:[tr.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:w.label}),jsx(Text,{style:[tr.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium}],selectable:true,children:w.value})]})]},w.label))]}),l?.last_error?jsx(View,{style:[tr.card,{backgroundColor:r.errorBackground,borderRadius:o.card.borderRadius}],children:jsxs(View,{style:tr.cardRow,children:[jsx(Text,{style:[tr.cardLabel,{color:r.error,fontFamily:n.regular}],children:"Error"}),jsx(Text,{style:[tr.cardValue,{color:r.error,fontFamily:n.medium,flex:1,textAlign:"right"}],selectable:true,children:l.last_error})]})}):null]})]})}var tr=StyleSheet.create({scroll:{flex:1,paddingTop:8},scrollContent:{paddingHorizontal:24,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},statusBadge:{position:"absolute",bottom:-4,right:-4,width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center",borderWidth:2},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14,marginBottom:2},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"}});function bh({count:e=4}){let{colors:t,components:r}=F(),o=useRef(new Animated.Value(.5)).current,n=t.cardHover??t.border,a=Math.min(r.card.borderRadius??12,14);return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:Mi.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[Mi.row,{backgroundColor:t.card,borderRadius:a,borderWidth:r.card.borderWidth,borderColor:t.border}],children:[jsxs(View,{style:Mi.left,children:[jsx(Animated.View,{style:[Mi.amountBar,{backgroundColor:n,opacity:o}]}),jsx(Animated.View,{style:[Mi.subtitleBar,{backgroundColor:n,opacity:o}]})]}),jsx(Animated.View,{style:[Mi.badgeBar,{backgroundColor:n,opacity:o}]})]},s))})}var Mi=StyleSheet.create({list:{gap:8},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16},left:{flex:1,gap:6},amountBar:{height:16,width:"40%",borderRadius:8},subtitleBar:{height:12,width:"55%",borderRadius:6},badgeBar:{height:20,width:80,borderRadius:6,marginLeft:12}});function Qa({initialAmount:e="",currency:t="USD",applePaySupported:r=false,hideQuickAmounts:o=false,maxAmount:n,paymentSelectorPosition:a="inline",onCollectPayment:i,paymentLoading:s=false,paymentStatus:l,paymentError:m,paymentTokens:c=[],onAddPaymentMethod:C,onConfirm:T,onCancel:y,sheetBorderTopLeftRadius:b,sheetBorderTopRightRadius:k,accessToken:h}){let p=Ei(),{colors:g,components:d,fonts:f}=F(),_=b??d.card.borderRadius,R=k??d.card.borderRadius,[w,S]=useState(e),[x,W]=useState(r?"apple_pay":c.length>0?c[0].id:null),D=useRef(false),O=U=>{D.current=true,W(U);};useEffect(()=>{D.current||r||c.length>0&&W(c[0].id);},[c,r]);let[P,j]=useState(false),[q,ae]=useState("select"),[Me,Oe]=useState(null),X=useRef(false);useEffect(()=>{s&&l&&/saving/i.test(l)&&ae("card");},[s,l]);let De=x==="apple_pay",he=1e3,xe=De?he:n,Ue=xe!=null&&xe>0,we=useMemo(()=>{if(o)return [];let U=mh.map(Q=>({label:`$${Q}`,amount:String(Q),disabled:false}));return De?U.push({label:`$${he}`,amount:String(he),disabled:false}):U.push({label:"MAX",amount:Ue?String(xe):"0",disabled:!Ue}),U},[o,Ue,xe,De]),ne=U=>{if(U==="\u232B"){S(Q=>Q.slice(0,-1));return}if(U==="."){if(w.includes("."))return;S(Q=>Q===""?"0.":Q+".");return}S(Q=>{let se=Q.indexOf(".");return se!==-1&&Q.length-se>2?Q:Q==="0"&&U!=="."?U:Q+U});},Ie=w===""?"0":w,mt=parseFloat(w),Ve=w!==""&&!isNaN(mt)&&mt>0,lt=r||c.length>0,He=a==="header",Ne=useMemo(()=>{let U=[];r&&U.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let Q of c)U.push({id:Q.id,label:hh(Q),hint:Q.card?`Expires ${Q.card.exp_month}/${Q.card.exp_year}`:Q.type,brand:Q.card?.brand,isApplePay:false});return U},[r,c]),je=Ne.find(U=>U.id===x),J=x!=null&&x!=="apple_pay",ce=je?je.label:J&&Me?Me:J?"Card":"Pay With",nt=je?!je.isApplePay:J,it=je?.brand??Me??void 0,[ve,be]=useState(false),[ie,de]=useState([]),[Qt,ue]=useState(false),[le,Ce]=useState(null),[wt,tt]=useState(null),pe=useRef(null);pe.current=wt;let Qe=useRef(false);Qe.current=ve;let ir=useCallback(async(U=false)=>{if(h){U||(ue(true),Ce(null));try{let Q=await Iu(h);if(!Qe.current)return;let se=Array.isArray(Q.data)?Q.data:Array.isArray(Q)?Q:[];de(se),U||Ce(null);let ze=pe.current?.id;if(ze){let E=se.find(te=>te.id===ze);E&&tt(E);}}catch(Q){if(!Qe.current)return;U||Ce(Q?.message??"Failed to load history");}finally{!U&&Qe.current&&ue(false);}}},[h]),xt=useCallback(()=>{be(true),ir();},[ir]);useEffect(()=>{if(!ve||!h)return;let U=setInterval(()=>ir(true),15e3);return ()=>clearInterval(U)},[ve,h,ir]);let Pr=h?jsx(TouchableOpacity,{style:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},onPress:xt,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"History",children:jsx(zr,{size:20,color:g.foreground,strokeWidth:2})}):void 0,Fr=lt?jsx(TouchableOpacity,{style:[He?p.amount.paymentRowHeader:p.amount.paymentRow,s&&{opacity:.5}],onPress:()=>{s||(ae("select"),j(true));},activeOpacity:.7,disabled:s,children:jsxs(View,{style:p.amount.paymentLeft,children:[je?.isApplePay?jsx(Text,{style:p.amount.applePayIcon,children:"\uF8FF"}):nt?jsx(Vc,{sublabel:it,size:20}):null,jsx(Text,{style:p.amount.paymentLabel,children:ce}),jsx(Bt,{size:12,color:p.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:p.form.screen,children:[jsx(Yt,{onPress:y,title:"Enter amount",leftAction:Pr}),He&&Fr,jsxs(View,{style:p.form.content,children:[jsxs(View,{style:p.amount.amountContainer,children:[jsxs(Text,{style:[p.amount.amountText,Ie==="0"&&p.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",Ie]}),jsx(Text,{style:p.amount.currencyLabel,children:t.toUpperCase()})]}),!He&&Fr,we.length>0&&jsx(View,{style:p.amount.quickRow,children:we.map(U=>{let Q=!U.disabled&&w===U.amount&&w!=="";return jsx(TouchableOpacity,{style:[p.amount.quickPill,Q&&{backgroundColor:g.primary},U.disabled&&{opacity:.4}],activeOpacity:.7,disabled:U.disabled||s,onPress:()=>S(U.amount),children:jsx(Text,{style:[p.amount.quickPillText,Q&&{color:g.primaryForeground}],children:U.label})},U.label)})}),jsx(View,{style:p.amount.numpad,children:fh.map((U,Q)=>jsx(View,{style:p.amount.numpadRow,children:U.map(se=>jsx(TouchableOpacity,{style:[p.amount.numpadKey,s&&{opacity:.3}],onPress:()=>ne(se),activeOpacity:.6,disabled:s,children:jsx(Text,{style:se==="\u232B"?p.amount.backspaceText:p.amount.numpadKeyText,children:se})},se))},Q))}),jsx(TouchableOpacity,{style:[p.form.continueBtn,(!Ve||s)&&p.form.continueBtnDisabled],onPress:()=>Ve&&!s&&T(w,x),disabled:!Ve||s,children:s?jsx(ActivityIndicator,{size:"small",color:g.primaryForeground}):jsx(Text,{style:[p.form.continueBtnText,!Ve&&p.form.continueBtnTextDisabled],children:"Continue"})}),!P&&m?jsx(Text,{style:p.amount.inlineError,children:m}):!P&&s&&l&&__DEV__?jsx(Text,{style:p.amount.inlineStatus,children:l}):null]}),jsx(ft,{visible:P,onClose:()=>{s||(j(false),ae("select"));},closeOnBackdropPress:!s,enablePanDownToClose:!s,showHandle:!s,heightPercent:.44,maxHeightPercent:.9,borderTopLeftRadius:_,borderTopRightRadius:R,children:jsx(View,{style:p.amount.sheetContent,children:q==="select"?jsxs(Fragment,{children:[jsxs(View,{style:p.amount.sheetTitleRow,children:[jsx(Text,{style:p.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity$1,{onPress:()=>j(false),activeOpacity:.7,style:p.amount.sheetCloseBtn,children:jsx(st,{size:16,color:g.foregroundMuted,strokeWidth:2.5})})]}),jsxs(ht,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[Ne.map(U=>{let Q=x===U.id;return jsxs(TouchableOpacity$1,{style:[p.amount.sheetOption,Q&&{borderColor:g.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{O(U.id),Oe(U.isApplePay?null:U.label),j(false);},children:[jsxs(View,{style:p.amount.sheetOptionLeft,children:[jsx(View,{style:p.amount.sheetOptionIcon,children:U.isApplePay?jsx(Text,{style:p.amount.applePayIcon,children:"\uF8FF"}):jsx(Vc,{sublabel:U.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:p.amount.sheetOptionLabel,children:U.label}),jsx(Text,{style:p.amount.sheetOptionHint,children:U.hint})]})]}),Q&&jsx($e,{size:18,color:g.primary,strokeWidth:2.5})]},U.id)}),jsx(TouchableOpacity$1,{style:p.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!X.current){X.current=true;try{let U=await C?.();U&&(O(U.token),Oe(U.sublabel),j(!1));}finally{X.current=false;}}},children:jsx(Text,{style:p.amount.addPaymentBtnText,children:"Add Payment Method"})})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:p.amount.sheetHeader,children:[jsx(TouchableOpacity$1,{onPress:()=>{s||ae("select");},activeOpacity:.7,style:p.amount.sheetBackBtn,children:jsx(Fi,{size:20,color:g.foreground,strokeWidth:2})}),jsx(Text,{style:p.amount.sheetTitle,children:"Pay With"})]}),s?jsxs(View,{style:p.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:g.primary}),__DEV__?jsx(Text,{style:p.amount.sheetStatusText,children:l||"Loading Stripe Link..."}):null]}):m?jsxs(Fragment,{children:[jsx(View,{style:p.amount.sheetError,children:jsx(Text,{style:p.amount.sheetErrorText,children:m})}),jsx(TouchableOpacity$1,{style:p.form.continueBtn,onPress:()=>{i&&Ve&&i(false,w);},children:jsx(Text,{style:p.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:p.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:g.primary}),__DEV__?jsx(Text,{style:p.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})}),jsx(ft,{visible:ve,onClose:()=>{be(false),tt(null);},closeOnBackdropPress:true,enablePanDownToClose:true,showHandle:true,heightPercent:.9,borderTopLeftRadius:_,borderTopRightRadius:R,children:wt?jsx(yh,{session:wt,onBack:()=>tt(null)}):jsxs(View,{style:p.amount.sheetContent,children:[jsx(Yt,{onPress:()=>be(false),title:"Purchase History"}),Qt?jsx(bh,{}):le?jsx(View,{style:p.amount.sheetError,children:jsx(Text,{style:p.amount.sheetErrorText,children:le})}):ie.length===0?jsx(View,{style:p.amount.sheetLoading,children:jsx(Text,{style:[p.amount.sheetStatusText,{color:g.foregroundMuted}],children:"No purchases yet"})}):jsx(ht,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:ie.map(U=>{let Q=U.transaction_details,se=Q?.source_amount?`$${parseFloat(Q.source_amount).toFixed(2)}`:"\u2014",ze=(Q?.destination_currency??"").toUpperCase(),E=Q?.destination_amount?`${parseFloat(Q.destination_amount).toFixed(2)} ${ze}`:"",te=Wu(U.created),ye=U.destination_token_metadata,me=Cn(ye?.icon_urls,ye?.icon_url),gt=Cn(ye?.chain?.icon_urls,ye?.chain?.icon_url);return jsxs(TouchableOpacity$1,{style:p.amount.sheetOption,activeOpacity:.7,onPress:()=>tt(U),children:[jsx(Es,{currency:ze||"USD",tokenIconUrl:me,networkIconUrl:gt,size:36}),jsxs(View,{style:{flex:1,gap:2,marginLeft:12},children:[jsx(Text,{style:p.amount.sheetOptionLabel,children:se}),E?jsx(Text,{style:p.amount.sheetOptionHint,children:E}):null]}),jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:8},children:[jsxs(View,{style:{alignItems:"flex-end",gap:2},children:[jsx(gh,{status:U.status,colors:g,fontFamily:f.regular}),te?jsx(Text,{style:{fontSize:11,color:g.foregroundMuted,fontFamily:f.regular},children:te}):null]}),jsx(Tr,{size:14,color:g.foregroundMuted,strokeWidth:2})]})]},U.id)})})]})})]})}var Us=4;function Ka({initialData:e={},loading:t=false,onComplete:r,onCancel:o}){let n=Ei(),{colors:a,fonts:i,components:s}=F(),l=s.input.placeholderColor,[m,c]=useState(1),[C,T]=useState(e.firstName??""),[y,b]=useState(e.lastName??""),[k,h]=useState(e.dobMonth??""),[p,g]=useState(e.dobDay??""),[d,f]=useState(e.dobYear??""),[_,R]=useState(e.addressLine1??""),[w,S]=useState(e.addressLine2??""),[x,W]=useState(e.city??""),[D,O]=useState(e.state??""),[P,j]=useState(e.postalCode??""),[q,ae]=useState(e.country??"US"),[Me,Oe]=useState(e.idNumber??""),X=useRef(null),De=useRef(null),he=useRef(null),xe=useRef(null),Ue=useRef(null),we=useRef(null),ne=useRef(null),Ie=useRef(null),mt=()=>{switch(m){case 1:return C.trim().length>0&&y.trim().length>0;case 2:return k.length===2&&p.length===2&&d.length===4;case 3:return _.trim().length>0&&x.trim().length>0&&D.trim().length>0&&P.trim().length>0;case 4:return Me.trim().length>0;default:return false}},Ve=()=>{mt()&&(m<Us?c(Be=>Be+1):r({firstName:C,lastName:y,idNumber:Me,dobMonth:k,dobDay:p,dobYear:d,addressLine1:_,addressLine2:w,city:x,state:D,postalCode:P,country:q}));},lt=()=>{m>1?c(Be=>Be-1):o();},He=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],Ne=["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."],je=[Ht.stepCounter,{color:a.foregroundMuted},...i.semibold?[{fontFamily:i.semibold}]:[]];return jsx(KeyboardAvoidingView,{style:n.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:n.form.screen,children:[jsxs(View,{style:Ht.header,children:[jsx(View,{style:Ht.headerSide,children:jsx(TouchableOpacity,{style:Ht.iconButton,onPress:lt,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:m>1?"Back":"Cancel",children:jsx(_s,{size:20,color:s.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:Ht.headerCenter,children:jsxs(Text,{style:je,children:[m," of ",Us]})}),jsx(View,{style:Ht.headerSide,children:jsx(TouchableOpacity,{style:Ht.iconButton,onPress:o,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(st,{size:20,color:s.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:Ht.progressTrack,children:Array.from({length:Us}).map((Be,J)=>jsx(View,{style:[Ht.progressSegment,{backgroundColor:J<m||J+1===m?a.primary:a.border}]},J))}),jsxs(ht,{style:n.form.flex,contentContainerStyle:Ht.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:n.form.title,children:He[m-1]}),jsx(Text,{style:n.form.subtitle,children:Ne[m-1]}),m===1&&jsxs(Fragment,{children:[jsx(Ko,{form:n.form,label:"First name",children:jsx(TextInput,{style:n.form.input,placeholder:"Jane",placeholderTextColor:l,value:C,onChangeText:T,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>X.current?.focus()})}),jsx(Ko,{form:n.form,label:"Last name",children:jsx(TextInput,{ref:X,style:n.form.input,placeholder:"Doe",placeholderTextColor:l,value:y,onChangeText:b,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:Ve})})]}),m===2&&jsxs(View,{style:Ht.dobRow,children:[jsxs(View,{style:Ht.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Ht.dobLabel],children:"Month"}),jsx(TextInput,{style:[n.form.input,Ht.dobInput],placeholder:"MM",placeholderTextColor:l,value:k,onChangeText:Be=>{let J=Be.replace(/\D/g,"").slice(0,2);h(J),J.length===2&&De.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Ht.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Ht.dobLabel],children:"Day"}),jsx(TextInput,{ref:De,style:[n.form.input,Ht.dobInput],placeholder:"DD",placeholderTextColor:l,value:p,onChangeText:Be=>{let J=Be.replace(/\D/g,"").slice(0,2);g(J),J.length===2&&he.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Ht.dobColWide,children:[jsx(Text,{style:[n.form.fieldLabel,Ht.dobLabel],children:"Year"}),jsx(TextInput,{ref:he,style:[n.form.input,Ht.dobInput],placeholder:"YYYY",placeholderTextColor:l,value:d,onChangeText:Be=>{let J=Be.replace(/\D/g,"").slice(0,4);f(J);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:Ve})]})]}),m===3&&jsxs(Fragment,{children:[jsx(Ko,{form:n.form,label:"Street address",children:jsx(TextInput,{style:n.form.input,placeholder:"123 Main St",placeholderTextColor:l,value:_,onChangeText:R,returnKeyType:"next",onSubmitEditing:()=>xe.current?.focus()})}),jsx(Ko,{form:n.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:xe,style:n.form.input,placeholder:"Apt 2",placeholderTextColor:l,value:w,onChangeText:S,returnKeyType:"next",onSubmitEditing:()=>Ue.current?.focus()})}),jsx(Ko,{form:n.form,label:"City",children:jsx(TextInput,{ref:Ue,style:n.form.input,placeholder:"San Francisco",placeholderTextColor:l,value:x,onChangeText:W,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>we.current?.focus()})}),jsxs(View,{style:Ht.row,children:[jsx(View,{style:[n.form.flex,{marginRight:8}],children:jsx(Ko,{form:n.form,label:"State",children:jsx(TextInput,{ref:we,style:n.form.input,placeholder:"NY",placeholderTextColor:l,value:D,onChangeText:Be=>O(Be.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>ne.current?.focus()})})}),jsx(View,{style:n.form.flex,children:jsx(Ko,{form:n.form,label:"ZIP code",children:jsx(TextInput,{ref:ne,style:n.form.input,placeholder:"11201",placeholderTextColor:l,value:P,onChangeText:j,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>Ie.current?.focus()})})})]}),jsx(Ko,{form:n.form,label:"Country",children:jsx(TextInput,{ref:Ie,style:n.form.input,placeholder:"US",placeholderTextColor:l,value:q,onChangeText:Be=>ae(Be.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:Ve})})]}),m===4&&jsxs(Ko,{form:n.form,label:"Social Security Number",children:[jsx(TextInput,{style:n.form.input,placeholder:"123-45-6789",placeholderTextColor:l,value:Me,onChangeText:Oe,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:Ve}),jsx(Text,{style:[n.form.hint,Ht.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:n.form.footer,children:t&&m===Us?jsx(View,{style:[n.form.continueBtn,n.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[n.form.continueBtn,!mt()&&n.form.continueBtnDisabled],onPress:Ve,disabled:!mt(),children:jsx(Text,{style:[n.form.continueBtnText,!mt()&&n.form.continueBtnTextDisabled],children:m===Us?"Submit":"Continue"})})})]})})}function Ko({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var Ht=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 Ec="@unifold/stripe_oauth";async function Uu(){try{let e=await Wc.getItem(Ec);return e?JSON.parse(e):null}catch{return null}}async function Mc(e){try{await Wc.setItem(Ec,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function Tn(){try{await Wc.removeItem(Ec);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Rh=5,_n=null,Hu={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Ga(e){let t=e?.flowOrder==="amount_first",r=t?"session_params":"email",{configure:o,hasLinkAccount:n,registerLinkUser:a,authorize:i,attachKycInfo:s,presentKycInfoVerification:l,verifyIdentity:m,registerWalletAddress:c,collectPaymentMethod:C,createCryptoPaymentToken:T}=useOnramp(),[y,b]=useState(r),[k,h]=useState(!!e?.externalUserId),[p,g]=useState(false),[d,f]=useState(""),[_,R]=useState(null),[w,S]=useState(e?.email??""),[x,W]=useState(e?.phone??""),[D,O]=useState(""),[P,j]=useState("US"),[q,ae]=useState(""),[Me,Oe]=useState(""),X=useRef(""),De=useRef(""),he=useRef(""),[xe,Ue]=useState(false),[we,ne]=useState(false),Ie=useRef(0),mt=useRef(false),Ve=useRef(false),lt=useRef(false),He=useRef(""),Ne=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),je=useRef(null),[Be,J]=useState(Hu),[ce,nt]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[it,ve]=useState(""),[be,ie]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[de,Qt]=useState(e?.defaultSourceAmount??"100"),[ue,le]=useState(e?.defaultSourceCurrency??"usd"),[Ce,wt]=useState(e?.defaultDestinationCurrency??"usdc"),[tt,pe]=useState(null),[Qe,ir]=useState(),[xt,Pr]=useState(),[Fr,U]=useState(false),Q=useRef(null),se=useRef(false),ze=useRef(0),E=useRef(e?.onComplete),te=useRef(e?.onError),ye=useRef(e?.onStepChange),me=useRef(r);useEffect(()=>{E.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{te.current=e?.onError;},[e?.onError]),useEffect(()=>{ye.current=e?.onStepChange;},[e?.onStepChange]);let gt=useRef(r);useEffect(()=>{y!==gt.current&&(ye.current?.(y,gt.current),gt.current=y),me.current=y;},[y]),useEffect(()=>{k&&y!==r&&h(false);},[k,y,r]);let V=useCallback((I,v,N)=>{let G={code:I,message:v,step:me.current,stripeErrorCode:N};R(G),f(""),te.current?.(G);},[]),Or=useCallback(I=>{let v={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 E.current?.(v),v},[]),z=useCallback(()=>R(null),[]),Ft=I=>I.refresh_token??I.refresh?.refresh_token??"",St=useCallback((I,v,N,G,_e)=>{De.current=v,X.current=N,e?.externalUserId&&Mc({accessToken:v,refreshToken:N,customerId:I,externalUserId:e.externalUserId,email:_e||w,expiresAt:Date.now()+G*1e3});},[e?.externalUserId,w]),Mr=useCallback(async()=>{let I=X.current;if(!I)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let v=await Pc(I,he.current??void 0),N=v.access_token,G=Ft(v)||I;return Oe(N),St(he.current,N,G,v.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),N}catch(v){return console.error("[tryRefreshAccessToken] refresh failed:",v?.message),await Tn(),_n=null,De.current="",X.current="",he.current="",Oe(""),ae(""),null}},[St]),Xt=useCallback(async I=>{try{return await I(De.current)}catch(v){let N=v?.message??"";if(N.includes("stripe_onramp_forbidden")||N.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let G=await Mr();if(!G)throw V("authorization_error","Session expired. Please sign in again."),b("email"),v;return await I(G)}throw v}},[Mr,V]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){U(false);return}let v=false;return isPlatformPaySupported().then(N=>{v||U(N);}),()=>{v=true;}},[e?.merchantIdentifier]),useEffect(()=>(se.current=false,()=>{se.current=true,Q.current&&clearTimeout(Q.current);}),[]);let Ii=useRef(false);useEffect(()=>{if(Ii.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),Tn(),_n=null,h(false);return}let I=false;return (async()=>{try{let v=await Uu();if(I||!v){I||h(!1);return}if(v.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",v.externalUserId,"current:",e.externalUserId),await Tn(),_n=null,I||h(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",v.customerId);let N=Date.now()>=v.expiresAt,G=v.accessToken,_e=v.refreshToken;if(N){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let Ke=await Pc(v.refreshToken,v.customerId);if(I)return;G=Ke.access_token,_e=Ke.refresh_token??Ke.refresh?.refresh_token??v.refreshToken,await Mc({accessToken:G,refreshToken:_e,customerId:v.customerId,externalUserId:e.externalUserId,email:v.email,expiresAt:Date.now()+(Ke.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(Ke){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",Ke?.message),await Tn(),_n=null,I||h(!1);return}}if(I)return;if(Ii.current=!0,ae(v.customerId),he.current=v.customerId,Oe(G),De.current=G,X.current=_e,v.email&&S(v.email),_n===v.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",v.customerId,"\u2014 skipping configure()"),je.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",v.customerId);let Ke=await o({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}},cryptoCustomerId:v.customerId});Ke.error?console.error("[useStripeOnramp] restore configureSDK error:",Ke.error.message):_n=v.customerId,je.current=Promise.resolve(Ke);}if(I)return;let yt=()=>new Promise(Ke=>{let yr=()=>{lt.current&&He.current?Ke():setTimeout(yr,200);};yr();});try{if(await Promise.race([yt(),new Promise((yr,Mt)=>setTimeout(()=>Mt(new Error("timeout")),1e4))]),I)return;let Ke=He.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",Ke,"network:",Ne.current),await c(Ke,Ne.current);}catch(Ke){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",Ke?.message);}if(I)return;console.log("[useStripeOnramp] credentials restored, skipping to session_params"),b("session_params");}finally{I||h(false);}})(),()=>{I=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||xe||we)return;let I=false;ne(true);async function v(){try{let[N,G]=await Promise.all([Fu({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?Ou({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(zt=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",zt?.message),null)):Promise.resolve(null)]);if(I)return;let _e=e?.destinationChainType??"ethereum",yt=N.data.find(zt=>zt.chain_type===_e);if(yt?.address){let zt=yt.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",zt,"recipient:",yt.recipient_address),nt(zt),He.current=zt,yt.recipient_address&&ve(yt.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",_e,"in",N.data?.length,"wallets");let Ke={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},yr={8453:"base",1:"ethereum",137:"polygon"},Mt=G?.destination_network,pr="none";if(Mt&&Ke[Mt])ie(Ke[Mt]),Ne.current=Ke[Mt],pr=Mt+" (from default_token API)";else if(e?.destinationChainId&&yr[e.destinationChainId]){let zt=yr[e.destinationChainId];Ke[zt]&&(ie(Ke[zt]),Ne.current=Ke[zt]),pr=zt+" (from chain_id "+e.destinationChainId+")";}else Ke[_e]&&(ie(Ke[_e]),Ne.current=Ke[_e],pr=_e+" (from chain_type fallback)");G?.destination_currency&&wt(G.destination_currency.toLowerCase());let ar=G?.destination_token_metadata,Jr=Cn(ar?.icon_urls,ar?.icon_url),Zr=Cn(ar?.chain?.icon_urls,ar?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",Jr,"network:",Zr),Jr&&ir(Jr),Zr&&Pr(Zr),Ue(!0),lt.current=!0;}catch(N){console.error("[useStripeOnramp] Failed to resolve wallet:",N?.message),Ue(true),lt.current=true;}finally{I||ne(false);}}return v(),()=>{I=true;}},[e?.publishableKey,e?.externalUserId]);let uo=useCallback(async()=>{if(je.current)return je.current;let I=o({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(v=>(v.error&&(console.error("[useStripeOnramp] configureSDK error:",v.error.message,v.error.code),je.current=null),v)).catch(v=>{throw console.error("[useStripeOnramp] configureSDK threw:",v?.message??v),je.current=null,v});return je.current=I,I},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||uo();},[]);let Ho=useCallback(async I=>{if(!mt.current){mt.current=true,g(true),z(),f("Creating auth intent...");try{let v=await vc(I);f("Waiting for authorization...");let N=await i(v);if(N?.error){console.log("[proceedToAuthorize] authorize error:",N.error.message),V("authorization_error","Something went wrong during authorization. Please try again."),b("email");return}if(N?.status==="Denied"){V("authorization_error","Authorization denied by user."),b("email");return}if(N?.status!=="Consented"||!N.customerId){V("authorization_error","Authorization was canceled."),b("email");return}f("Exchanging tokens...");let G=N.customerId,_e=await xu(v,G),yt=_e.access_token,Ke=Ft(_e);console.log("[useStripeOnramp] customerId:",G),console.log("[useStripeOnramp] accessToken acquired, length:",yt.length),ae(G),he.current=G,_n=G,Oe(yt),St(G,yt,Ke,_e.expires_in??3600),f("Checking verification status...");try{let yr=await ja(G,yt),Mt=yr.verifications.find(hn=>hn.name==="kyc_verified"),pr=yr.verifications.find(hn=>hn.name==="id_document_verified"),ar=Mt?.status==="verified",Jr=Mt?.status==="rejected",Zr=pr?.status==="verified",zt=yr.provided_fields.includes("first_name");if(f(""),Jr&&!zt)V("kyc_error","KYC was previously rejected. Please submit with correct info."),b("kyc");else if(Jr&&zt)b(Zr?"wallet":"identity");else if(!ar&&!zt)b("kyc");else if(!Zr)b("identity");else if(lt.current&&He.current)try{let hn=He.current.toLowerCase();console.log("[proceedToAuthorize] registering wallet:",hn,"network:",be);let Sa=await c(hn,be);Sa?.error?(console.warn("[proceedToAuthorize] wallet registration error:",Sa.error.message),V("wallet_error",Sa.error.message,Sa.error.code),b("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),b("session_params"));}catch(hn){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",hn?.message),b("wallet");}else b("wallet");}catch(yr){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",yr?.message),f(""),b("kyc");}}catch(v){V("authorization_error",v?.message??String(v)),b("email");}finally{mt.current=false,g(false);}}},[i,z,V,St,c,be]),K=useCallback(async()=>{if(Keyboard.dismiss(),!w){V("validation_error","Please enter an email address.");return}g(true),z(),f("");try{f("Configuring...");let I=await uo();if(I.error){V("configuration_error",I.error.message,I.error.code);return}f("Checking Link account...");let v=await n(w);if(v.error){V("authorization_error",v.error.message,v.error.code);return}v.hasLinkAccount?await Ho(w):(f(""),b("register"));}catch(I){V("unknown_error",I?.message??String(I));}finally{g(false);}},[z,uo,w,V,n,Ho]),ge=useCallback(async()=>{if(!x){V("validation_error","Please enter your phone number.");return}g(true),z(),f("");try{f("Creating Link account...");let I=await a({email:w,phone:x,fullName:D||w,country:P||"US"});if(I.error){V("registration_error",I.error.message,I.error.code);return}await Ho(w);}catch(I){V("registration_error",I?.message??String(I));}finally{g(false);}},[z,P,w,V,D,x,a,Ho]);useEffect(()=>{if(y!=="email"||!e?.email||k)return;let I=++Ie.current,v=false,N=()=>v||Ie.current!==I;return e?.phone?(async()=>{g(true),z();try{f("Configuring...");let G=await uo();if(N())return;if(G.error){V("configuration_error",G.error.message,G.error.code);return}f("Checking Link account...");let _e=await n(e.email);if(N())return;if(_e.error){V("authorization_error",_e.error.message,_e.error.code);return}if(_e.hasLinkAccount){if(N())return;await Ho(e.email);}else {f("Creating Link account...");let yt=await a({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(N())return;if(yt.error){V("registration_error",yt.error.message,yt.error.code);return}if(N())return;await Ho(e.email);}}catch(G){N()||V("unknown_error",G?.message??String(G));}finally{g(false);}})():(async()=>{g(true),z();try{f("Configuring...");let G=await uo();if(N())return;if(G.error){V("configuration_error",G.error.message,G.error.code);return}f("Checking Link account...");let _e=await n(e.email);if(N())return;if(_e.error){V("authorization_error",_e.error.message,_e.error.code);return}if(_e.hasLinkAccount){if(N())return;await Ho(e.email);}else {if(N())return;f(""),b("register");}}catch(G){N()||V("unknown_error",G?.message??String(G));}finally{g(false);}})(),()=>{v=true;}},[y,e?.email,e?.phone,k]);let Lt=useCallback(async I=>{g(true),z(),f(""),J(I);try{let v={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}},N=await s(v);if(N?.error){if(N.error.stripeErrorCode==="consumer_person_already_verified"){f(""),b("identity");return}V("kyc_error",N.error.message,N.error.stripeErrorCode??N.error.code),b("kyc");return}f("Please review your KYC information...");let G=await l(null);if(G?.error){V("kyc_error",G.error.message,G.error.stripeErrorCode??G.error.code),b("kyc");return}if(G?.status==="UpdateAddress"){V("kyc_error","Please update your address and resubmit."),b("kyc");return}f(""),b("identity");}catch(v){V("kyc_error",v?.message??String(v)),b("kyc");}finally{g(false);}},[s,z,V,l]),po=useCallback(async()=>{if(!Ve.current){Ve.current=true,g(true),z(),f("Launching identity verification...");try{let I=await m();if(I?.error){V("identity_error",I.error.message,I.error.code);return}f(""),b("wallet");}catch(I){V("identity_error",I?.message??String(I));}finally{Ve.current=false,g(false);}}},[z,V,m]);useEffect(()=>{y==="identity"&&!p&&po();},[y]);let ks=useCallback(async()=>{if(!ce){V("validation_error","Please enter a wallet address.");return}g(true),z(),f("");try{let I=ce.toLowerCase();console.log("[registerWallet] registering wallet:",I,"network:",be);let v=await c(I,be);if(v?.error){console.warn("[registerWallet] error:",v.error.message),V("wallet_error",v.error.message,v.error.code);return}console.log("[registerWallet] wallet registered successfully"),f(""),b("session_params");}catch(I){V("wallet_error",I?.message??String(I));}finally{g(false);}},[z,V,ce,be,c]);useEffect(()=>{y==="wallet"&&xe&&ce&&ks();},[y,xe,ce]);let mo=useCallback(I=>{se.current=false,ze.current=0;let v=0,N=async()=>{v+=1;let G=De.current;try{let _e=await vu(I,G);if(console.log(`[pollSessionStatus] poll #${v} session=${I} status="${_e.status}"`),se.current)return;ze.current=0,_e.status==="fulfillment_complete"?(pe(_e),b("success")):Q.current=setTimeout(N,3e3);}catch(_e){if(se.current)return;let yt=_e?.message??"";if((yt.includes("stripe_onramp_forbidden")||yt.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await Mr()&&!se.current)){Q.current=setTimeout(N,1e3);return}if(ze.current+=1,console.error(`[pollSessionStatus] poll #${v} error:`,yt),ze.current>=Rh){V("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}Q.current=setTimeout(N,5e3);}};Q.current=setTimeout(N,3e3);},[V,Mr]),fn=useCallback(()=>{if(me.current==="processing"&&tt?.id){if(!De.current){V("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}z(),ze.current=0,Q.current&&(clearTimeout(Q.current),Q.current=null),mo(tt.id);}},[z,V,mo,tt?.id]),wa=useCallback(async I=>{g(true),z(),f("");try{f("Confirming purchase...");let v=await Xt(N=>Ru(I,N));console.log("[finalizeOnrampSession] confirmed session:",v.id,"status:",v.status),pe(v),b("processing"),f(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",v.id),mo(v.id);}finally{g(false);}},[z,mo,Xt]),Xl=useRef(false),Ym=useCallback(async()=>{if(!(!tt||Xl.current)){Xl.current=true;try{g(!0),z(),f("Refreshing quote...");let I=await Xt(v=>Fc(tt.id,v));pe(I),await wa(I.id);}catch(I){console.log("[confirmCheckout] error:",I?.message),V("session_error","Something went wrong. Please try again."),b("quote");}finally{g(false),Xl.current=false;}}},[z,V,wa,tt,Xt]),eu=useCallback(async()=>{let I=w;if(!I)return console.warn("[reauthorizeLink] no email available for re-authorization"),false;try{console.log("[reauthorizeLink] re-establishing Link session for:",I),f("Verifying identity...");let v=await vc(I),N=await i(v);return N?.status==="Consented"&&N.customerId?(console.log("[reauthorizeLink] re-authorized successfully, customerId:",N.customerId),he.current=N.customerId,ae(N.customerId),_n=N.customerId,!0):(console.warn("[reauthorizeLink] authorize did not consent:",N?.status),!1)}catch(v){return console.warn("[reauthorizeLink] failed:",v?.message),false}},[i,w]),Jm=useCallback(async(I=false,v,N)=>{let G=v??de;if(console.log("[collectPaymentMethod] called:",{useApplePay:I,amt:G,amountOverride:v,sourceAmount:de,hasSavedToken:!!N}),!G||isNaN(Number(G))||Number(G)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),V("validation_error","Please enter a valid amount.");return}v&&Qt(v),g(true),z(),f("");try{let _e=await uo();if(_e.error){V("configuration_error",_e.error.message,_e.error.code);return}let yt;if(N)console.log("[collectPaymentMethod] using saved payment token"),yt=N;else if(I){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),V("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),b("session_params");return}f("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let Mt={applePay:{merchantCountryCode:"US",currencyCode:ue.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${Ce.toUpperCase()} purchase + fees`,amount:G}]}},pr=await C("PlatformPay",Mt);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!pr?.error),pr?.error){let Jr=pr.error.message??"",Zr=pr.error.code??"",zt=/cancel/i.test(Jr)||/cancel/i.test(Zr);console.log("[collectPaymentMethod] pmResult error:",pr.error,"isCancellation:",zt),zt||(V("payment_error",Jr,Zr),b("session_params"));return}if(!pr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}f("Creating payment token...");let ar=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!ar?.error),ar?.error){V("payment_error",ar.error.message,ar.error.code),b("session_params");return}yt=ar.cryptoPaymentToken;}else {f("Select a payment method...");let Mt=await C("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Mt?.error),Mt?.error){let Jr=Mt.error.message??"",Zr=Mt.error.code??"",zt=/cancel/i.test(Jr)||/cancel/i.test(Zr);console.log("[collectPaymentMethod] pmResult error:",Mt.error,"isCancellation:",zt),zt||(V("payment_error",Jr,Zr),b("session_params"));return}if(!Mt?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let pr=Mt.displayData;console.log("[collectPaymentMethod] displayData:",{type:pr.type,label:pr.label,sublabel:pr.sublabel,hasIcon:!!pr.icon}),f("Creating payment token...");let ar=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!ar?.error),ar?.error){V("payment_error",ar.error.message,ar.error.code),b("session_params");return}yt=ar.cryptoPaymentToken;}f("Creating onramp session..."),console.log("[collectPaymentMethod] creating onramp session, walletAddress:",ce,"walletAddressRef:",He.current);let Ke=He.current||ce.toLowerCase(),yr=await Xt(Mt=>_u({cryptoCustomerId:he.current,paymentToken:yt,sourceAmount:Number(G),sourceCurrency:ue,destinationCurrency:Ce,walletAddress:Ke,destinationNetwork:be},Mt));console.log("[collectPaymentMethod] session created:",yr?.id,"useApplePay:",I),pe(yr),f(""),I?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await wa(yr.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):b("quote");}catch(_e){console.log("[collectPaymentMethod] error caught:",_e?.message),V("session_error","Something went wrong. Please try again."),b("session_params");}finally{g(false),f("");}},[z,uo,C,T,Ce,V,wa,Qt,de,ue,ce,be,Xt,e?.merchantIdentifier]),Zm=useCallback(async()=>{g(true),z(),f("Select a payment method...");try{let I=await uo();if(I.error)return V("configuration_error",I.error.message,I.error.code),null;let v=await C("Card");if(console.log("[addPaymentMethod] Card result ok:",!v?.error),v?.error?.message&&/no active link consumer/i.test(v.error.message)){if(console.log("[addPaymentMethod] no active Link consumer \u2014 attempting re-authorization"),!await eu())return V("authorization_error","Please verify your identity to add a payment method."),null;v=await C("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!v?.error);}if(v?.error){let _e=v.error.message??"",yt=v.error.code??"",Ke=/cancel/i.test(_e)||/cancel/i.test(yt);return console.log("[addPaymentMethod] pmResult error:",v.error,"isCancellation:",Ke),Ke||V("payment_error",_e,yt),null}if(!v?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let N=v.displayData;console.log("[addPaymentMethod] displayData:",{type:N.type,label:N.label,sublabel:N.sublabel,hasIcon:!!N.icon}),f("Saving payment method...");let G=await T();return console.log("[addPaymentMethod] tokenResult ok:",!G?.error),G?.error?(V("payment_error",G.error.message,G.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:G.cryptoPaymentToken,sublabel:N.sublabel??""})}catch(I){return console.log("[addPaymentMethod] error:",I?.message),V("session_error",I?.message??String(I)),null}finally{g(false),f("");}},[z,uo,C,T,V,eu]),Xm=useCallback(async()=>{if(tt){g(true),z(),f("");try{let I=await Xt(v=>Fc(tt.id,v));pe(I);}catch(I){console.log("[refreshQuote] error:",I?.message),V("session_error","Something went wrong. Please try again.");}finally{g(false);}}},[z,V,tt,Xt]),ef=useCallback(()=>{se.current=true,ze.current=0,Q.current&&(clearTimeout(Q.current),Q.current=null),b(r),g(false),f(""),R(null),S(e?.email??""),W(e?.phone??""),O(""),j("US"),ae(""),he.current="",Oe(""),De.current="",X.current="",Ue(false),ne(false),J(Hu),nt(e?.recipientAddress??""),He.current="",lt.current=false,ie(Onramp.CryptoNetwork.ethereum),Qt(e?.defaultSourceAmount??"100"),le(e?.defaultSourceCurrency??"usd"),wt(e?.defaultDestinationCurrency??"usdc"),ve(""),ir(void 0),Pr(void 0),pe(null),Ie.current+=1,mt.current=false,Ve.current=false;},[e,r]);return {step:y,restoring:k,loading:p,status:d,error:_,email:w,phone:x,fullName:D,country:P,customerId:q,accessToken:Me,session:tt,kycData:Be,walletAddress:ce,resolvedRecipientAddress:it,walletNetwork:be,sourceAmount:de,sourceCurrency:ue,destinationCurrency:Ce,tokenIconUrl:Qe,networkIconUrl:xt,applePaySupported:Fr,walletReady:xe,walletLoading:we,setStep:b,setStatus:f,setEmail:S,setPhone:W,setFullName:O,setCountry:j,setWalletAddress:nt,setWalletNetwork:ie,setSourceAmount:Qt,setSourceCurrency:le,setDestinationCurrency:wt,checkEmail:K,register:ge,attachKyc:Lt,verifyIdentity:po,registerWallet:ks,collectPaymentMethod:Jm,addPaymentMethod:Zm,refreshQuote:Xm,confirmCheckout:Ym,reset:ef,clearError:z,emitComplete:Or,resumeFulfillmentPolling:fn,amountFirst:t}}function Nu({styles:e,placeholderColor:t,hasPrefilledEmail:r,loading:o,error:n,status:a,email:i,setEmail:s,checkEmail:l,onClose:m}){return r?jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(kt,{size:56,strokeWidth:3}),jsx(_r,{error:n,progress:a,loading:o})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:m}),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:t,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:i,onChangeText:s,autoFocus:true,returnKeyType:"done",onSubmitEditing:l})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:l,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(_r,{error:n,progress:a,loading:o})]})]})})}function $u({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:a}){return jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:a}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(kt,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Verifying identity"}),jsx(Text,{style:e.flow.sub,children:r||"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:r||"Tap below to continue verification."})]}),jsx(_r,{error:o,progress:r,loading:false})]}),!t&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:n,children:jsx(Text,{style:e.form.continueBtnText,children:"Continue Verification"})})})]})}function Qu({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,onClose:m,onRetryStatusCheck:c}){let{colors:C}=F(),T=!!t;return jsxs(View,{style:e.form.screen,children:[T?jsx(Yt,{onPress:m}):jsx(View,{style:Ea}),jsx(View,{style:e.flow.centered,children:t?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(kt,{size:48,strokeWidth:3,gradientFrom:C.primary,gradientTo:C.primary})}),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."]}),n&&a&&i&&jsx(za,{sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(_r,{error:t,progress:r,loading:o}),t?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:c,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function Ku({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:a,tokenIconUrl:i,networkIconUrl:s,onClose:l,onBack:m}){let{colors:c}=F(),C=t.transaction_details,T=Wa(C.destination_amount,C.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:m??l,title:"Review your purchase",variant:m?"back":"close"}),jsxs(View,{style:e.form.content,children:[jsx(View,{style:{alignItems:"center",marginTop:24,marginBottom:20},children:jsx(Es,{currency:C.destination_currency,tokenIconUrl:i,networkIconUrl:s,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(fo,{quote:e.quote,label:"You pay",value:`${C.source_amount} ${C.source_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"You receive",value:`${T} ${C.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Network fee",value:`$${C.fees.network_fee_amount}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Transaction fee",value:`$${C.fees.transaction_fee_amount}`,last:true})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2,gradientFrom:c.primaryForeground,gradientTo:c.primaryForeground})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:a,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(_r,{error:o,progress:n,loading:r})]})]})}function Gu({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:a,phone:i,setPhone:s,register:l,onClose:m}){let c=F();return t?jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(kt,{size:56,strokeWidth:3}),jsx(_r,{error:o,progress:n,loading:r})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:m}),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:c.components.input.placeholderColor,keyboardType:"phone-pad",value:i,onChangeText:C=>s(C.replace(/[^\d+]/g,"").replace(/(?!^)\+/g,"")),autoFocus:true,returnKeyType:"done",onSubmitEditing:l}),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:a})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:l,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(_r,{error:o,progress:n,loading:r})]})]})})}function Hh({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=F(),n=e.toLowerCase(),a=Ma[n]??o.primary,i=Math.round(r*.36);return jsxs(View,{style:{width:r,height:r,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:r,height:r,borderRadius:r/2}}):jsx(View,{style:[Io.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:a}],children:jsx(Text,{style:[Io.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[Io.checkBadge,{width:i,height:i,borderRadius:i/2,backgroundColor:o.success,borderColor:o.background}],children:jsx($e,{size:i*.55,color:"#FFFFFF",strokeWidth:3})})]})}function Yu({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:a,onDone:i}){let {colors:s,components:l,fonts:m}=F(),c=t.transaction_details,C=Wa(c.destination_amount,c.destination_currency),T=r||o||"";Wi(c.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:i,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(ht,{style:e.form.flex,contentContainerStyle:Io.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Io.iconSection,children:[jsx(Hh,{currency:c.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:Io.statusRow,children:[jsx(View,{style:[Io.statusDot,{backgroundColor:s.success}]}),jsx(Text,{style:[Io.statusText,{color:s.foreground,fontFamily:m.semibold}],children:"Completed"})]}),jsx(Text,{style:[Io.subtitle,{color:s.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(za,{sourceCurrency:c.source_currency,destinationCurrency:c.destination_currency,destinationNetwork:c.destination_network,tokenIconUrl:n,networkIconUrl:a,style:{marginBottom:12}}),jsxs(View,{style:[e.quote.card,{borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor},Io.detailCard],children:[jsx(fo,{quote:e.quote,label:"You Paid",value:`${c.source_amount} ${c.source_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"You Received",value:`${C} ${c.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Network Fee",value:`$${c.fees.network_fee_amount}`,hideDivider:true}),jsx(fo,{quote:e.quote,label:"Transaction Fee",value:`$${c.fees.transaction_fee_amount}`,hideDivider:true}),jsx(Ic,{quote:e.quote,label:"Intent Address",address:c.wallet_address,hideDivider:true}),T?jsx(Ic,{quote:e.quote,label:"Recipient Address",address:T,last:true}):jsx(fo,{quote:e.quote,label:"Session",value:t.id.slice(0,8)+"..."+t.id.slice(-6),last:true})]})]})}),jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:i,children:jsx(Text,{style:e.form.continueBtnText,children:"Done"})})})]})}var Io=StyleSheet.create({scrollContent:{paddingBottom:24,alignItems:"center"},iconSection:{alignItems:"center",marginTop:24,marginBottom:24},tokenCircle:{alignItems:"center",justifyContent:"center"},tokenLetter:{color:"#FFFFFF",fontWeight:"700",letterSpacing:.5},checkBadge:{position:"absolute",bottom:0,right:0,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",marginTop:16,gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16},subtitle:{fontSize:14,marginTop:4},detailCard:{width:"100%"}});function Ju({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:a,walletNetwork:i,setWalletAddress:s,setWalletNetwork:l,setDestinationCurrency:m,registerWallet:c,onClose:C}){let{components:T}=F();if(t){let y=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:C}),jsxs(View,{style:e.flow.centered,children:[!y&&jsx(kt,{size:56,strokeWidth:3}),jsx(_r,{error:o,progress:n,loading:r})]}),y&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:c,children:jsx(Text,{style:e.form.continueBtnText,children:"Retry"})})})]})}return jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(Yt,{onPress:C}),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:T.input.placeholderColor,autoCapitalize:"none",autoCorrect:false,value:a,onChangeText:s})]}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Network"}),jsx(View,{style:e.wallet.list,children:Ba.map(y=>{let b=i===y.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,b&&e.wallet.rowSelected],onPress:()=>{l(y.value),m(y.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(y.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,b&&e.wallet.rowTextSelected],children:y.label}),b&&jsx(View,{style:e.wallet.checkCircle,children:jsx($e,{size:14,color:T.container.buttonTitleColor,strokeWidth:2.5})})]},y.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(kt,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!a&&e.form.continueBtnDisabled],onPress:c,disabled:!a,children:jsx(Text,{style:[e.form.continueBtnText,!a&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(_r,{error:o,progress:n,loading:r})]})]})})}function el({config:e,onClose:t}){let r=F(),o=Ei(),{step:n,restoring:a,loading:i,status:s,error:l,email:m,phone:c,session:C,kycData:T,walletAddress:y,resolvedRecipientAddress:b,walletNetwork:k,sourceAmount:h,sourceCurrency:p,destinationCurrency:g,tokenIconUrl:d,networkIconUrl:f,applePaySupported:_,setStep:R,setEmail:w,setPhone:S,setWalletAddress:x,setWalletNetwork:W,setSourceAmount:D,setDestinationCurrency:O,checkEmail:P,register:j,attachKyc:q,verifyIdentity:ae,registerWallet:Me,collectPaymentMethod:Oe,addPaymentMethod:X,confirmCheckout:De,reset:he,emitComplete:xe,resumeFulfillmentPolling:Ue,amountFirst:we,customerId:ne,accessToken:Ie}=Ga(e),mt=!!e?.email,Ve=!!e?.phone,lt=!!e?.publishableKey&&!!e?.externalUserId,[He,Ne]=useState(void 0),[je,Be]=useState([]);useEffect(()=>{if(a||n!=="session_params"||!ne||!Ie)return;console.log("[OnrampScreen] customerId:",ne);let ve=ie=>{let de=ie?.message??"";return de.includes("stripe_onramp_forbidden")||de.includes("403")},be=ie=>{ve(ie)&&(Tn(),he());};ja(ne,Ie).then(ie=>{console.log("[OnrampScreen] customer fetched, id:",ie?.id);}).catch(ie=>{console.warn("[OnrampScreen] customer fetch error:",ie?.message),be(ie);}),Oc(ne,Ie).then(ie=>{console.log("[OnrampScreen] payment_tokens fetched, count:",ie.data?.length??0),Be(ie.data??[]);}).catch(ie=>{console.warn("[OnrampScreen] payment_tokens error:",ie?.message),be(ie);}),console.log("[OnrampScreen] walletAddress:",y,"walletNetwork:",k),y&&(console.log("[OnrampScreen] calling getTransactionLimits..."),Pu({destinationNetwork:k||"ethereum",walletAddress:y,accessToken:Ie,cryptoCustomerId:ne}).then(ie=>{console.log("[OnrampScreen] transaction_limits fetched");let de=ie.limits?.usd;if(de?.card?.length){let Qt=Math.max(...de.card.map(ue=>ue.limit));Ne(Qt),console.log("[OnrampScreen] card max amount:",Qt);}}).catch(ie=>{console.warn("[OnrampScreen] transaction_limits error:",ie?.message),be(ie);}));},[a,n,ne,Ie,y,k,he]);let J=async()=>{if(!(!ne||!Ie))try{let ve=await Oc(ne,Ie);console.log("[OnrampScreen] payment_tokens refreshed, count:",ve.data?.length??0),Be(ve.data??[]);}catch(ve){console.warn("[OnrampScreen] payment_tokens refresh error:",ve?.message);let be=ve?.message??"";(be.includes("stripe_onramp_forbidden")||be.includes("403"))&&(Tn(),he());}},ce=async()=>{let ve=await X();return ve&&await J(),ve},nt=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&nt&&C&&(xe(C),he(),t?.());},[n,nt,C,xe,he,t]);let it=()=>{he(),t?.();};return a?jsx(View,{style:[Kh.container,{backgroundColor:r.colors.background}],children:jsx(kt,{size:56,strokeWidth:3,gradientFrom:r.colors.primary,gradientTo:r.colors.primary})}):n==="email"?jsx(Nu,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:mt,loading:i,error:l,status:s,email:m,setEmail:w,checkEmail:P,onClose:it}):n==="register"?jsx(Gu,{styles:o,hasPrefilledPhone:Ve,loading:i,error:l,status:s,email:m,phone:c,setPhone:S,register:j,onClose:it}):n==="kyc"?jsx(Ka,{initialData:T,loading:i,onComplete:q,onCancel:()=>R("email")}):n==="identity"?jsx($u,{styles:o,loading:i,status:s,error:l,verifyIdentity:ae,onClose:it}):n==="wallet"?jsx(Ju,{styles:o,hasAutoWallet:lt,loading:i,error:l,status:s,walletAddress:y,walletNetwork:k,setWalletAddress:x,setWalletNetwork:W,setDestinationCurrency:O,registerWallet:Me,onClose:it}):n==="session_params"?jsx(Qa,{initialAmount:h,currency:p,applePaySupported:_,paymentSelectorPosition:e?.paymentSelectorPosition??"header",maxAmount:He,paymentTokens:je,onAddPaymentMethod:ce,onCollectPayment:(ve,be)=>{Oe(ve,be);},paymentLoading:i,paymentStatus:s,paymentError:l?.message??null,onConfirm:(ve,be)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:ve,selectedMethod:be,amountFirst:we}),we&&!ne)D(ve),R("email");else {let ie=be==="apple_pay",de=!ie&&be?be:void 0;console.log("[OnrampScreen] isApplePay:",ie,"hasSavedToken:",!!de),Oe(ie,ve,de);}},onCancel:it,accessToken:Ie}):n==="quote"&&C?jsx(Ku,{styles:o,session:C,loading:i,error:l,status:s,confirmCheckout:De,tokenIconUrl:d,networkIconUrl:f,onClose:it,onBack:()=>R("session_params")}):n==="processing"?jsx(Qu,{styles:o,error:l,status:s,loading:i,sourceCurrency:C?.transaction_details.source_currency,destinationCurrency:C?.transaction_details.destination_currency??g,destinationNetwork:C?.transaction_details.destination_network??"base",tokenIconUrl:d,networkIconUrl:f,onClose:it,onRetryStatusCheck:Ue}):n==="success"&&C&&!nt?jsx(Yu,{styles:o,session:C,resolvedRecipientAddress:b,recipientFromConfig:e?.recipientAddress,tokenIconUrl:d,networkIconUrl:f,onDone:()=>{xe(C),he(),t?.();}}):null}var Kh=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center"}});function ep(){try{let e=Gh.expoConfig?.plugins;if(!Array.isArray(e))return;for(let t of e){if(!Array.isArray(t))continue;let[r,o]=t;if(r!=="@stripe/stripe-react-native"||!o||typeof o!="object")continue;let n=o.merchantIdentifier;if(typeof n=="string"){let a=n.trim();if(a.length>0)return a}}}catch{}}function tl({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:a="ethereum",destinationChainId:i="8453",destinationTokenAddress:s,recipientAddress:l,onComplete:m,onError:c,onStepChange:C,onClose:T,merchantIdentifier:y="",urlScheme:b="unifoldOnramp",paymentSelectorPosition:k,skipSuccessConfirmation:h=false}){let{colors:p,fonts:g,components:d}=F(),f=e||Pa(),_=useMemo(()=>{let D=y.trim();return D.length>0?D:ep()??""},[y]),[R,w]=useState("loading"),[S,x]=useState(null);useEffect(()=>{let D=false;async function O(){try{f&&(Ua(f),Ha(Ds()));let P=await Na();if(D)return;let j=_.trim();if(await initStripe({publishableKey:P,urlScheme:b,...j?{merchantIdentifier:j}:{}}),D)return;w("ready");}catch(P){if(D)return;console.error("[StripeOnramp] Init failed:",P),x(P?.message??"Failed to load Stripe configuration"),w("error");}}return O(),()=>{D=true;}},[f,_,b]);let W=useMemo(()=>{let D={publishableKey:f,externalUserId:o,destinationChainType:a,destinationChainId:i,onComplete:m,onError:c,onStepChange:C};return s&&(D.destinationTokenAddress=s),l&&(D.recipientAddress=l),t&&(D.email=t),r&&(D.phone=r),n&&(D.flowOrder=n),k&&(D.paymentSelectorPosition=k),D.skipSuccessConfirmation=h,D.merchantIdentifier=_,D},[f,o,a,i,s,l,t,r,n,k,h,_,m,c,C]);return R==="error"?jsxs(View,{style:[ji.centered,{backgroundColor:p.background}],children:[jsx(Text,{style:[ji.errorText,{color:p.error,fontFamily:g.medium}],children:"Unable to initialize"}),jsx(Text,{style:[ji.errorDetail,{color:p.foregroundMuted,fontFamily:g.regular}],children:S}),T&&jsx(TouchableOpacity,{style:[ji.retryBtn,{backgroundColor:d.button.primaryBackground,borderRadius:d.button.borderRadius}],onPress:T,children:jsx(Text,{style:[ji.retryBtnText,{color:d.button.primaryText,fontFamily:g.medium}],children:"Go Back"})})]}):R==="loading"?jsx(View,{style:[ji.centered,{backgroundColor:p.background}],children:jsx(kt,{size:56,strokeWidth:3,gradientFrom:p.primary,gradientTo:p.primary})}):jsx(el,{config:W,onClose:T})}var ji=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",paddingHorizontal:24},errorText:{fontSize:18,marginBottom:8},errorDetail:{fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{paddingVertical:14,paddingHorizontal:32},retryBtnText:{fontSize:16}});function np(){let{configure:e}=useOnramp(),t=useRef(false);return useEffect(()=>{t.current||(t.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(r=>{r.error&&console.error("[StripeOnrampPreconfigure] error:",r.error.message);}).catch(r=>{console.error("[StripeOnrampPreconfigure] threw:",r?.message);}));},[e]),null}var ip="__unifold_stripe_onramp__";function rl(e){globalThis[ip]=e;}function sp(){return globalThis[ip]}rl(tl);var vo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this);}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe();}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var oi,vn,$i,ap,ng=(ap=class extends vo{constructor(){super();ee(this,oi);ee(this,vn);ee(this,$i);A(this,$i,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){u(this,vn)||this.setEventListener(u(this,$i));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,vn))==null||t.call(this),A(this,vn,void 0));}setEventListener(t){var r;A(this,$i,t),(r=u(this,vn))==null||r.call(this),A(this,vn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){u(this,oi)!==t&&(A(this,oi,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof u(this,oi)=="boolean"?u(this,oi):globalThis.document?.visibilityState!=="hidden"}},oi=new WeakMap,vn=new WeakMap,$i=new WeakMap,ap),qi=new ng;var ig={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Po,ni,lp,sg=(lp=class{constructor(){ee(this,Po,ig);ee(this,ni,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&u(this,ni)&&e!==u(this,Po)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:u(this,Po),provider:e}),A(this,Po,e),process.env.NODE_ENV!=="production"&&A(this,ni,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&A(this,ni,true),u(this,Po).setTimeout(e,t)}clearTimeout(e){u(this,Po).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&A(this,ni,true),u(this,Po).setInterval(e,t)}clearInterval(e){u(this,Po).clearInterval(e);}},Po=new WeakMap,ni=new WeakMap,lp),Fo=new sg;function cp(e){setTimeout(e,0);}var Nc=typeof window>"u"||"Deno"in globalThis;function or(){}function pp(e,t){return typeof e=="function"?e(t):e}function qs(e){return typeof e=="number"&&e>=0&&e!==1/0}function nl(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bo(e,t){return typeof e=="function"?e(t):e}function Br(e,t){return typeof e=="function"?e(t):e}function il(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:a,queryKey:i,stale:s}=e;if(i){if(o){if(t.queryHash!==Qs(i,t.options))return false}else if(!ai(t.queryKey,i))return false}if(r!=="all"){let l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return false}return !(typeof s=="boolean"&&t.isStale()!==s||n&&n!==t.state.fetchStatus||a&&!a(t))}function sl(e,t){let{exact:r,status:o,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return false;if(r){if(ii(t.options.mutationKey)!==ii(a))return false}else if(!ai(t.options.mutationKey,a))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Qs(e,t){return (t?.queryKeyHashFn||ii)(e)}function ii(e){return JSON.stringify(e,(t,r)=>Hc(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function ai(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>ai(e[r],t[r])):false}var ag=Object.prototype.hasOwnProperty;function ol(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=dp(e)&&dp(t);if(!o&&!(Hc(e)&&Hc(t)))return t;let a=(o?e:Object.keys(e)).length,i=o?t:Object.keys(t),s=i.length,l=o?new Array(s):{},m=0;for(let c=0;c<s;c++){let C=o?c:i[c],T=e[C],y=t[C];if(T===y){l[C]=T,(o?c<a:ag.call(e,C))&&m++;continue}if(T===null||y===null||typeof T!="object"||typeof y!="object"){l[C]=y;continue}let b=ol(T,y,r+1);l[C]=b,b===T&&m++;}return a===s&&m===a?e:l}function al(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return false;for(let r in e)if(e[r]!==t[r])return false;return true}function dp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Hc(e){if(!up(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!up(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function up(e){return Object.prototype.toString.call(e)==="[object Object]"}function mp(e){return new Promise(t=>{Fo.setTimeout(t,e);})}function Ks(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==false){if(process.env.NODE_ENV!=="production")try{return ol(e,t)}catch(o){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${o}`),o}return ol(e,t)}return t}function fp(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function hp(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var si=Symbol();function ll(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===si&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===si?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function cl(e,t){return typeof e=="function"?e(...t):!!e}function gp(e,t,r){let o=false,n;return Object.defineProperty(e,"signal",{enumerable:true,get:()=>(n??(n=t()),o||(o=true,n.aborted?r():n.addEventListener("abort",r,{once:true})),n)}),e}var Oo=(()=>{let e=()=>Nc;return {isServer(){return e()},setIsServer(t){e=t;}}})();function Gs(){let e,t,r=new Promise((n,a)=>{e=n,t=a;});r.status="pending",r.catch(()=>{});function o(n){Object.assign(r,n),delete r.resolve,delete r.reject;}return r.resolve=n=>{o({status:"fulfilled",value:n}),e(n);},r.reject=n=>{o({status:"rejected",reason:n}),t(n);},r}var yp=cp;function lg(){let e=[],t=0,r=s=>{s();},o=s=>{s();},n=yp,a=s=>{t?e.push(s):n(()=>{r(s);});},i=()=>{let s=e;e=[],s.length&&n(()=>{o(()=>{s.forEach(l=>{r(l);});});});};return {batch:s=>{let l;t++;try{l=s();}finally{t--,t||i();}return l},batchCalls:s=>(...l)=>{a(()=>{s(...l);});},schedule:a,setNotifyFunction:s=>{r=s;},setBatchNotifyFunction:s=>{o=s;},setScheduler:s=>{n=s;}}}var It=lg();var Qi,Pn,Ki,bp,cg=(bp=class extends vo{constructor(){super();ee(this,Qi,true);ee(this,Pn);ee(this,Ki);A(this,Ki,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t(true),o=()=>t(false);return window.addEventListener("online",r,false),window.addEventListener("offline",o,false),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o);}}});}onSubscribe(){u(this,Pn)||this.setEventListener(u(this,Ki));}onUnsubscribe(){var t;this.hasListeners()||((t=u(this,Pn))==null||t.call(this),A(this,Pn,void 0));}setEventListener(t){var r;A(this,Ki,t),(r=u(this,Pn))==null||r.call(this),A(this,Pn,t(this.setOnline.bind(this)));}setOnline(t){u(this,Qi)!==t&&(A(this,Qi,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return u(this,Qi)}},Qi=new WeakMap,Pn=new WeakMap,Ki=new WeakMap,bp),Gi=new cg;function dg(e){return Math.min(1e3*2**e,3e4)}function jc(e){return (e??"online")==="online"?Gi.isOnline():true}var dl=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function ul(e){let t=false,r=0,o,n=Gs(),a=()=>n.status!=="pending",i=k=>{if(!a()){let h=new dl(k);T(h),e.onCancel?.(h);}},s=()=>{t=true;},l=()=>{t=false;},m=()=>qi.isFocused()&&(e.networkMode==="always"||Gi.isOnline())&&e.canRun(),c=()=>jc(e.networkMode)&&e.canRun(),C=k=>{a()||(o?.(),n.resolve(k));},T=k=>{a()||(o?.(),n.reject(k));},y=()=>new Promise(k=>{o=h=>{(a()||m())&&k(h);},e.onPause?.();}).then(()=>{o=void 0,a()||e.onContinue?.();}),b=()=>{if(a())return;let k,h=r===0?e.initialPromise:void 0;try{k=h??e.fn();}catch(p){k=Promise.reject(p);}Promise.resolve(k).then(C).catch(p=>{if(a())return;let g=e.retry??(Oo.isServer()?0:3),d=e.retryDelay??dg,f=typeof d=="function"?d(r,p):d,_=g===true||typeof g=="number"&&r<g||typeof g=="function"&&g(r,p);if(t||!_){T(p);return}r++,e.onFail?.(r,p),mp(f).then(()=>m()?void 0:y()).then(()=>{t?T(p):b();});});};return {promise:n,status:()=>n.status,cancel:i,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?b():y().then(b),n)}}var li,Cp,pl=(Cp=class{constructor(){ee(this,li);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),qs(this.gcTime)&&A(this,li,Fo.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Oo.isServer()?1/0:300*1e3));}clearGcTimeout(){u(this,li)!==void 0&&(Fo.clearTimeout(u(this,li)),A(this,li,void 0));}},li=new WeakMap,Cp);var ci,Yi,so,di,cr,Ys,ui,Qr,xp,Yo,kp,Tp=(kp=class extends pl{constructor(t){super();ee(this,Qr);ee(this,ci);ee(this,Yi);ee(this,so);ee(this,di);ee(this,cr);ee(this,Ys);ee(this,ui);A(this,ui,false),A(this,Ys,t.defaultOptions),this.setOptions(t.options),this.observers=[],A(this,di,t.client),A(this,so,u(this,di).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,A(this,ci,Sp(this.options)),this.state=t.state??u(this,ci),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return u(this,cr)?.promise}setOptions(t){if(this.options={...u(this,Ys),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=Sp(this.options);r.data!==void 0&&(this.setState(wp(r.data,r.dataUpdatedAt)),A(this,ci,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&u(this,so).remove(this);}setData(t,r){let o=Ks(this.state.data,t,this.options);return Ae(this,Qr,Yo).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Ae(this,Qr,Yo).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=u(this,cr)?.promise;return u(this,cr)?.cancel(t),r?r.then(or).catch(or):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return u(this,ci)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Br(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===si||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bo(t.options.staleTime,this)==="static"):false}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?true:t==="static"?false:this.state.isInvalidated?true:!nl(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),u(this,cr)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),u(this,cr)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),u(this,so).notify({type:"observerAdded",query:this,observer:t}));}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(u(this,cr)&&(u(this,ui)||Ae(this,Qr,xp).call(this)?u(this,cr).cancel({revert:true}):u(this,cr).cancelRetry()),this.scheduleGc()),u(this,so).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ae(this,Qr,Yo).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&u(this,cr)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(u(this,cr))return u(this,cr).continueRetry(),u(this,cr).promise}if(t&&this.setOptions(t),!this.options.queryFn){let l=this.observers.find(m=>m.options.queryFn);l&&this.setOptions(l.options);}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));let o=new AbortController,n=l=>{Object.defineProperty(l,"signal",{enumerable:true,get:()=>(A(this,ui,true),o.signal)});},a=()=>{let l=ll(this.options,r),c=(()=>{let C={client:u(this,di),queryKey:this.queryKey,meta:this.meta};return n(C),C})();return A(this,ui,false),this.options.persister?this.options.persister(l,c,this):l(c)},s=(()=>{let l={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:u(this,di),state:this.state,fetchFn:a};return n(l),l})();this.options.behavior?.onFetch(s,this),A(this,Yi,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&Ae(this,Qr,Yo).call(this,{type:"fetch",meta:s.fetchOptions?.meta}),A(this,cr,ul({initialPromise:r?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof dl&&l.revert&&this.setState({...u(this,Yi),fetchStatus:"idle"}),o.abort();},onFail:(l,m)=>{Ae(this,Qr,Yo).call(this,{type:"failed",failureCount:l,error:m});},onPause:()=>{Ae(this,Qr,Yo).call(this,{type:"pause"});},onContinue:()=>{Ae(this,Qr,Yo).call(this,{type:"continue"});},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>true}));try{let l=await u(this,cr).start();if(l===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(l),u(this,so).config.onSuccess?.(l,this),u(this,so).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof dl){if(l.silent)return u(this,cr).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Ae(this,Qr,Yo).call(this,{type:"error",error:l}),u(this,so).config.onError?.(l,this),u(this,so).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},ci=new WeakMap,Yi=new WeakMap,so=new WeakMap,di=new WeakMap,cr=new WeakMap,Ys=new WeakMap,ui=new WeakMap,Qr=new WeakSet,xp=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Yo=function(t){let r=o=>{switch(t.type){case "failed":return {...o,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case "pause":return {...o,fetchStatus:"paused"};case "continue":return {...o,fetchStatus:"fetching"};case "fetch":return {...o,...$c(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...wp(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return A(this,Yi,t.manual?n:void 0),n;case "error":let a=t.error;return {...o,error:a,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:true};case "invalidate":return {...o,isInvalidated:true};case "setState":return {...o,...t.state}}};this.state=r(this.state),It.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),u(this,so).notify({query:this,type:"updated",action:t});});},kp);function $c(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:jc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function wp(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function Sp(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,o=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return {data:t,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:false,status:r?"success":"pending",fetchStatus:"idle"}}var Ar,Ge,Zs,Rr,pi,Ji,Jo,Fn,Xs,Zi,Xi,mi,fi,On,es,dt,Js,qc,Qc,Kc,Gc,Yc,Jc,Zc,vp,Ip,ed=(Ip=class extends vo{constructor(t,r){super();ee(this,dt);ee(this,Ar);ee(this,Ge);ee(this,Zs);ee(this,Rr);ee(this,pi);ee(this,Ji);ee(this,Jo);ee(this,Fn);ee(this,Xs);ee(this,Zi);ee(this,Xi);ee(this,mi);ee(this,fi);ee(this,On);ee(this,es,new Set);this.options=r,A(this,Ar,t),A(this,Fn,null),A(this,Jo,Gs()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(u(this,Ge).addObserver(this),_p(u(this,Ge),this.options)?Ae(this,dt,Js).call(this):this.updateResult(),Ae(this,dt,Gc).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Xc(u(this,Ge),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Xc(u(this,Ge),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ae(this,dt,Yc).call(this),Ae(this,dt,Jc).call(this),u(this,Ge).removeObserver(this);}setOptions(t){let r=this.options,o=u(this,Ge);if(this.options=u(this,Ar).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Br(this.options.enabled,u(this,Ge))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ae(this,dt,Zc).call(this),u(this,Ge).setOptions(this.options),r._defaulted&&!al(this.options,r)&&u(this,Ar).getQueryCache().notify({type:"observerOptionsUpdated",query:u(this,Ge),observer:this});let n=this.hasListeners();n&&Rp(u(this,Ge),o,this.options,r)&&Ae(this,dt,Js).call(this),this.updateResult(),n&&(u(this,Ge)!==o||Br(this.options.enabled,u(this,Ge))!==Br(r.enabled,u(this,Ge))||bo(this.options.staleTime,u(this,Ge))!==bo(r.staleTime,u(this,Ge)))&&Ae(this,dt,qc).call(this);let a=Ae(this,dt,Qc).call(this);n&&(u(this,Ge)!==o||Br(this.options.enabled,u(this,Ge))!==Br(r.enabled,u(this,Ge))||a!==u(this,On))&&Ae(this,dt,Kc).call(this,a);}getOptimisticResult(t){let r=u(this,Ar).getQueryCache().build(u(this,Ar),t),o=this.createResult(r,t);return pg(this,o)&&(A(this,Rr,o),A(this,Ji,this.options),A(this,pi,u(this,Ge).state)),o}getCurrentResult(){return u(this,Rr)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&u(this,Jo).status==="pending"&&u(this,Jo).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){u(this,es).add(t);}getCurrentQuery(){return u(this,Ge)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=u(this,Ar).defaultQueryOptions(t),o=u(this,Ar).getQueryCache().build(u(this,Ar),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Ae(this,dt,Js).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),u(this,Rr)))}createResult(t,r){let o=u(this,Ge),n=this.options,a=u(this,Rr),i=u(this,pi),s=u(this,Ji),m=t!==o?t.state:u(this,Zs),{state:c}=t,C={...c},T=false,y;if(r._optimisticResults){let x=this.hasListeners(),W=!x&&_p(t,r),D=x&&Rp(t,o,r,n);(W||D)&&(C={...C,...$c(c.data,t.options)}),r._optimisticResults==="isRestoring"&&(C.fetchStatus="idle");}let{error:b,errorUpdatedAt:k,status:h}=C;y=C.data;let p=false;if(r.placeholderData!==void 0&&y===void 0&&h==="pending"){let x;a?.isPlaceholderData&&r.placeholderData===s?.placeholderData?(x=a.data,p=true):x=typeof r.placeholderData=="function"?r.placeholderData(u(this,Xi)?.state.data,u(this,Xi)):r.placeholderData,x!==void 0&&(h="success",y=Ks(a?.data,x,r),T=true);}if(r.select&&y!==void 0&&!p)if(a&&y===i?.data&&r.select===u(this,Xs))y=u(this,Zi);else try{A(this,Xs,r.select),y=r.select(y),y=Ks(a?.data,y,r),A(this,Zi,y),A(this,Fn,null);}catch(x){A(this,Fn,x);}u(this,Fn)&&(b=u(this,Fn),y=u(this,Zi),k=Date.now(),h="error");let g=C.fetchStatus==="fetching",d=h==="pending",f=h==="error",_=d&&g,R=y!==void 0,S={status:h,fetchStatus:C.fetchStatus,isPending:d,isSuccess:h==="success",isError:f,isInitialLoading:_,isLoading:_,data:y,dataUpdatedAt:C.dataUpdatedAt,error:b,errorUpdatedAt:k,failureCount:C.fetchFailureCount,failureReason:C.fetchFailureReason,errorUpdateCount:C.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:C.dataUpdateCount>m.dataUpdateCount||C.errorUpdateCount>m.errorUpdateCount,isFetching:g,isRefetching:g&&!d,isLoadingError:f&&!R,isPaused:C.fetchStatus==="paused",isPlaceholderData:T,isRefetchError:f&&R,isStale:td(t,r),refetch:this.refetch,promise:u(this,Jo),isEnabled:Br(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let x=S.data!==void 0,W=S.status==="error"&&!x,D=j=>{W?j.reject(S.error):x&&j.resolve(S.data);},O=()=>{let j=A(this,Jo,S.promise=Gs());D(j);},P=u(this,Jo);switch(P.status){case "pending":t.queryHash===o.queryHash&&D(P);break;case "fulfilled":(W||S.data!==P.value)&&O();break;case "rejected":(!W||S.error!==P.reason)&&O();break}}return S}updateResult(){let t=u(this,Rr),r=this.createResult(u(this,Ge),this.options);if(A(this,pi,u(this,Ge).state),A(this,Ji,this.options),u(this,pi).data!==void 0&&A(this,Xi,u(this,Ge)),al(r,t))return;A(this,Rr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!u(this,es).size)return true;let i=new Set(a??u(this,es));return this.options.throwOnError&&i.add("error"),Object.keys(u(this,Rr)).some(s=>{let l=s;return u(this,Rr)[l]!==t[l]&&i.has(l)})};Ae(this,dt,vp).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ae(this,dt,Gc).call(this);}},Ar=new WeakMap,Ge=new WeakMap,Zs=new WeakMap,Rr=new WeakMap,pi=new WeakMap,Ji=new WeakMap,Jo=new WeakMap,Fn=new WeakMap,Xs=new WeakMap,Zi=new WeakMap,Xi=new WeakMap,mi=new WeakMap,fi=new WeakMap,On=new WeakMap,es=new WeakMap,dt=new WeakSet,Js=function(t){Ae(this,dt,Zc).call(this);let r=u(this,Ge).fetch(this.options,t);return t?.throwOnError||(r=r.catch(or)),r},qc=function(){Ae(this,dt,Yc).call(this);let t=bo(this.options.staleTime,u(this,Ge));if(Oo.isServer()||u(this,Rr).isStale||!qs(t))return;let o=nl(u(this,Rr).dataUpdatedAt,t)+1;A(this,mi,Fo.setTimeout(()=>{u(this,Rr).isStale||this.updateResult();},o));},Qc=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(u(this,Ge)):this.options.refetchInterval)??false},Kc=function(t){Ae(this,dt,Jc).call(this),A(this,On,t),!(Oo.isServer()||Br(this.options.enabled,u(this,Ge))===false||!qs(u(this,On))||u(this,On)===0)&&A(this,fi,Fo.setInterval(()=>{(this.options.refetchIntervalInBackground||qi.isFocused())&&Ae(this,dt,Js).call(this);},u(this,On)));},Gc=function(){Ae(this,dt,qc).call(this),Ae(this,dt,Kc).call(this,Ae(this,dt,Qc).call(this));},Yc=function(){u(this,mi)!==void 0&&(Fo.clearTimeout(u(this,mi)),A(this,mi,void 0));},Jc=function(){u(this,fi)!==void 0&&(Fo.clearInterval(u(this,fi)),A(this,fi,void 0));},Zc=function(){let t=u(this,Ar).getQueryCache().build(u(this,Ar),this.options);if(t===u(this,Ge))return;let r=u(this,Ge);A(this,Ge,t),A(this,Zs,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},vp=function(t){It.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(u(this,Rr));}),u(this,Ar).getQueryCache().notify({query:u(this,Ge),type:"observerResultsUpdated"});});},Ip);function ug(e,t){return Br(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function _p(e,t){return ug(e,t)||e.state.data!==void 0&&Xc(e,t,t.refetchOnMount)}function Xc(e,t,r){if(Br(t.enabled,e)!==false&&bo(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&td(e,t)}return false}function Rp(e,t,r,o){return (e!==t||Br(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&td(e,r)}function td(e,t){return Br(t.enabled,e)!==false&&e.isStaleByTime(bo(t.staleTime,e))}function pg(e,t){return !al(e.getCurrentResult(),t)}function rd(e){return {onFetch:(t,r)=>{let o=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,a=t.state.data?.pages||[],i=t.state.data?.pageParams||[],s={pages:[],pageParams:[]},l=0,m=async()=>{let c=false,C=b=>{gp(b,()=>t.signal,()=>c=true);},T=ll(t.options,t.fetchOptions),y=async(b,k,h)=>{if(c)return Promise.reject();if(k==null&&b.pages.length)return Promise.resolve(b);let g=(()=>{let R={client:t.client,queryKey:t.queryKey,pageParam:k,direction:h?"backward":"forward",meta:t.options.meta};return C(R),R})(),d=await T(g),{maxPages:f}=t.options,_=h?hp:fp;return {pages:_(b.pages,d,f),pageParams:_(b.pageParams,k,f)}};if(n&&a.length){let b=n==="backward",k=b?mg:Pp,h={pages:a,pageParams:i},p=k(o,h);s=await y(h,p,b);}else {let b=e??a.length;do{let k=l===0?i[0]??o.initialPageParam:Pp(o,s);if(l>0&&k==null)break;s=await y(s,k),l++;}while(l<b)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(m,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=m;}}}function Pp(e,{pages:t,pageParams:r}){let o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,r[o],r):void 0}function mg(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var ea,Do,Cr,hi,Vo,Dn,Fp,Op=(Fp=class extends pl{constructor(t){super();ee(this,Vo);ee(this,ea);ee(this,Do);ee(this,Cr);ee(this,hi);A(this,ea,t.client),this.mutationId=t.mutationId,A(this,Cr,t.mutationCache),A(this,Do,[]),this.state=t.state||fg(),this.setOptions(t.options),this.scheduleGc();}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime);}get meta(){return this.options.meta}addObserver(t){u(this,Do).includes(t)||(u(this,Do).push(t),this.clearGcTimeout(),u(this,Cr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){A(this,Do,u(this,Do).filter(r=>r!==t)),this.scheduleGc(),u(this,Cr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){u(this,Do).length||(this.state.status==="pending"?this.scheduleGc():u(this,Cr).remove(this));}continue(){return u(this,hi)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Ae(this,Vo,Dn).call(this,{type:"continue"});},o={client:u(this,ea),meta:this.options.meta,mutationKey:this.options.mutationKey};A(this,hi,ul({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(i,s)=>{Ae(this,Vo,Dn).call(this,{type:"failed",failureCount:i,error:s});},onPause:()=>{Ae(this,Vo,Dn).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>u(this,Cr).canRun(this)}));let n=this.state.status==="pending",a=!u(this,hi).canStart();try{if(n)r();else {Ae(this,Vo,Dn).call(this,{type:"pending",variables:t,isPaused:a}),u(this,Cr).config.onMutate&&await u(this,Cr).config.onMutate(t,this,o);let s=await this.options.onMutate?.(t,o);s!==this.state.context&&Ae(this,Vo,Dn).call(this,{type:"pending",context:s,variables:t,isPaused:a});}let i=await u(this,hi).start();return await u(this,Cr).config.onSuccess?.(i,t,this.state.context,this,o),await this.options.onSuccess?.(i,t,this.state.context,o),await u(this,Cr).config.onSettled?.(i,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(i,null,t,this.state.context,o),Ae(this,Vo,Dn).call(this,{type:"success",data:i}),i}catch(i){try{await u(this,Cr).config.onError?.(i,t,this.state.context,this,o);}catch(s){Promise.reject(s);}try{await this.options.onError?.(i,t,this.state.context,o);}catch(s){Promise.reject(s);}try{await u(this,Cr).config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,o);}catch(s){Promise.reject(s);}try{await this.options.onSettled?.(void 0,i,t,this.state.context,o);}catch(s){Promise.reject(s);}throw Ae(this,Vo,Dn).call(this,{type:"error",error:i}),i}finally{u(this,Cr).runNext(this);}}},ea=new WeakMap,Do=new WeakMap,Cr=new WeakMap,hi=new WeakMap,Vo=new WeakSet,Dn=function(t){let r=o=>{switch(t.type){case "failed":return {...o,failureCount:t.failureCount,failureReason:t.error};case "pause":return {...o,isPaused:true};case "continue":return {...o,isPaused:false};case "pending":return {...o,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case "success":return {...o,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:false};case "error":return {...o,data:void 0,error:t.error,failureCount:o.failureCount+1,failureReason:t.error,isPaused:false,status:"error"}}};this.state=r(this.state),It.batch(()=>{u(this,Do).forEach(o=>{o.onMutationUpdate(t);}),u(this,Cr).notify({mutation:this,type:"updated",action:t});});},Fp);function fg(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var Zo,Co,ta,Dp,Vp=(Dp=class extends vo{constructor(t={}){super();ee(this,Zo);ee(this,Co);ee(this,ta);this.config=t,A(this,Zo,new Set),A(this,Co,new Map),A(this,ta,0);}build(t,r,o){let n=new Op({client:t,mutationCache:this,mutationId:++Ts(this,ta)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){u(this,Zo).add(t);let r=ml(t);if(typeof r=="string"){let o=u(this,Co).get(r);o?o.push(t):u(this,Co).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(u(this,Zo).delete(t)){let r=ml(t);if(typeof r=="string"){let o=u(this,Co).get(r);if(o)if(o.length>1){let n=o.indexOf(t);n!==-1&&o.splice(n,1);}else o[0]===t&&u(this,Co).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=ml(t);if(typeof r=="string"){let n=u(this,Co).get(r)?.find(a=>a.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=ml(t);return typeof r=="string"?u(this,Co).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){It.batch(()=>{u(this,Zo).forEach(t=>{this.notify({type:"removed",mutation:t});}),u(this,Zo).clear(),u(this,Co).clear();});}getAll(){return Array.from(u(this,Zo))}find(t){let r={exact:true,...t};return this.getAll().find(o=>sl(r,o))}findAll(t={}){return this.getAll().filter(r=>sl(t,r))}notify(t){It.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return It.batch(()=>Promise.all(t.map(r=>r.continue().catch(or))))}},Zo=new WeakMap,Co=new WeakMap,ta=new WeakMap,Dp);function ml(e){return e.options.scope?.id}var Lo,Lp,Bp=(Lp=class extends vo{constructor(t={}){super();ee(this,Lo);this.config=t,A(this,Lo,new Map);}build(t,r,o){let n=r.queryKey,a=r.queryHash??Qs(n,r),i=this.get(a);return i||(i=new Tp({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){u(this,Lo).has(t.queryHash)||(u(this,Lo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=u(this,Lo).get(t.queryHash);r&&(t.destroy(),r===t&&u(this,Lo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){It.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return u(this,Lo).get(t)}getAll(){return [...u(this,Lo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>il(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>il(t,o)):r}notify(t){It.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){It.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){It.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Lo=new WeakMap,Lp);var $t,Vn,Ln,ts,rs,Bn,os,ns,Ap,od=(Ap=class{constructor(e={}){ee(this,$t);ee(this,Vn);ee(this,Ln);ee(this,ts);ee(this,rs);ee(this,Bn);ee(this,os);ee(this,ns);A(this,$t,e.queryCache||new Bp),A(this,Vn,e.mutationCache||new Vp),A(this,Ln,e.defaultOptions||{}),A(this,ts,new Map),A(this,rs,new Map),A(this,Bn,0);}mount(){Ts(this,Bn)._++,u(this,Bn)===1&&(A(this,os,qi.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,$t).onFocus());})),A(this,ns,Gi.subscribe(async e=>{e&&(await this.resumePausedMutations(),u(this,$t).onOnline());})));}unmount(){var e,t;Ts(this,Bn)._--,u(this,Bn)===0&&((e=u(this,os))==null||e.call(this),A(this,os,void 0),(t=u(this,ns))==null||t.call(this),A(this,ns,void 0));}isFetching(e){return u(this,$t).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return u(this,Vn).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,$t).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=u(this,$t).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(bo(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return u(this,$t).findAll(e).map(({queryKey:t,state:r})=>{let o=r.data;return [t,o]})}setQueryData(e,t,r){let o=this.defaultQueryOptions({queryKey:e}),a=u(this,$t).get(o.queryHash)?.state.data,i=pp(t,a);if(i!==void 0)return u(this,$t).build(this,o).setData(i,{...r,manual:true})}setQueriesData(e,t,r){return It.batch(()=>u(this,$t).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return u(this,$t).get(t.queryHash)?.state}removeQueries(e){let t=u(this,$t);It.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=u(this,$t);return It.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=It.batch(()=>u(this,$t).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(or).catch(or)}invalidateQueries(e,t={}){return It.batch(()=>(u(this,$t).findAll(e).forEach(r=>{r.invalidate();}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??true},o=It.batch(()=>u(this,$t).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,r);return r.throwOnError||(a=a.catch(or)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(o).then(or)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=u(this,$t).build(this,t);return r.isStaleByTime(bo(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(or).catch(or)}fetchInfiniteQuery(e){return e.behavior=rd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(or).catch(or)}ensureInfiniteQueryData(e){return e.behavior=rd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Gi.isOnline()?u(this,Vn).resumePausedMutations():Promise.resolve()}getQueryCache(){return u(this,$t)}getMutationCache(){return u(this,Vn)}getDefaultOptions(){return u(this,Ln)}setDefaultOptions(e){A(this,Ln,e);}setQueryDefaults(e,t){u(this,ts).set(ii(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...u(this,ts).values()],r={};return t.forEach(o=>{ai(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){u(this,rs).set(ii(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...u(this,rs).values()],r={};return t.forEach(o=>{ai(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...u(this,Ln).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Qs(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===si&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...u(this,Ln).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){u(this,$t).clear(),u(this,Vn).clear();}},$t=new WeakMap,Vn=new WeakMap,Ln=new WeakMap,ts=new WeakMap,rs=new WeakMap,Bn=new WeakMap,os=new WeakMap,ns=new WeakMap,Ap);var nd=An.createContext(void 0),id=e=>{let t=An.useContext(nd);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},sd=({client:e,children:t})=>(An.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(nd.Provider,{value:e,children:t}));var Wp=An.createContext(false),Ep=()=>An.useContext(Wp);Wp.Provider;function gg(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var yg=An.createContext(gg()),Mp=()=>An.useContext(yg);var Up=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?cl(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},Hp=e=>{An.useEffect(()=>{e.clearReset();},[e]);},Np=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||cl(r,[e.error,o]));var jp=e=>{if(e.suspense){let r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3));}},$p=(e,t)=>e.isLoading&&e.isFetching&&!t,qp=(e,t)=>e?.suspense&&t.isPending,ad=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function Qp(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let o=Ep(),n=Mp(),a=id(),i=a.defaultQueryOptions(e);a.getDefaultOptions().queries?._experimental_beforeQuery?.(i);let s=a.getQueryCache().get(i.queryHash);process.env.NODE_ENV!=="production"&&(i.queryFn||console.error(`[${i.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),i._optimisticResults=o?"isRestoring":"optimistic",jp(i),Up(i,n,s),Hp(n);let l=!a.getQueryCache().get(i.queryHash),[m]=An.useState(()=>new t(a,i)),c=m.getOptimisticResult(i),C=!o&&e.subscribed!==false;if(An.useSyncExternalStore(An.useCallback(T=>{let y=C?m.subscribe(It.batchCalls(T)):or;return m.updateResult(),y},[m,C]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),An.useEffect(()=>{m.setOptions(i);},[i,m]),qp(i,c))throw ad(i,m,n);if(Np({result:c,errorResetBoundary:n,throwOnError:i.throwOnError,query:s,suspense:i.suspense}))throw c.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,c),i.experimental_prefetchInRender&&!Oo.isServer()&&$p(c,o)&&(l?ad(i,m,n):s?.promise)?.catch(or).finally(()=>{m.updateResult();}),i.notifyOnChangeProps?c:m.trackResult(c)}function Xo(e,t){return Qp(e,ed)}var as=new Map;function Kp({width:e,height:t,borderRadius:r,color:o}){let n=useRef(new Animated.Value(.3)).current;return useEffect(()=>{let a=Animated.loop(Animated.sequence([Animated.timing(n,{toValue:.7,duration:800,useNativeDriver:true}),Animated.timing(n,{toValue:.3,duration:800,useNativeDriver:true})]));return a.start(),()=>a.stop()},[n]),jsx(Animated.View,{style:{position:"absolute",width:e,height:t,borderRadius:r,backgroundColor:o,opacity:n}})}function En({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:a="transparent",backgroundColor:i="transparent",style:s}){let{colors:l}=F(),[m,c]=useState(false),[C,T]=useState(false),[y,b]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let _=as.get(e);return _?{uri:e,xml:_}:null}),k=e?.toLowerCase().endsWith(".svg"),h=k&&e&&y?.uri===e?y.xml:null;useEffect(()=>{c(false),T(false);},[e]),useEffect(()=>{if(!k||!e)return;if(as.has(e)){b({uri:e,xml:as.get(e)});return}let _=false;return fetch(e).then(R=>{if(!R.ok)throw new Error(`HTTP ${R.status}`);return R.text()}).then(R=>{_||(as.set(e,R),b({uri:e,xml:R}));}).catch(()=>{_||c(true);}),()=>{_=true;}},[e,k]);let p=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:p},s]});let g={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:a,backgroundColor:i,overflow:"hidden",alignItems:"center",justifyContent:"center",...s},d=t-n*2,f=r-n*2;return m?jsx(View,{style:[g,{backgroundColor:i||p}]}):k?jsxs(View,{style:g,children:[!!!h&&jsx(Kp,{width:d,height:f,borderRadius:o,color:p}),h?jsx(SvgXml,{xml:h,width:d,height:f,onError:()=>c(true)}):jsx(SvgUri,{uri:e,width:d,height:f,onError:()=>c(true)})]}):jsxs(View,{style:g,children:[!C&&jsx(Kp,{width:d,height:f,borderRadius:o,color:p}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:d,height:f},resizeMode:"contain",onLoad:()=>T(true),onError:()=>c(true)})]})}function dd(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(as.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{as.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function Ir({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:a,badge:i,showBalance:s=false,balanceAddress:l,balanceChainType:m,balanceChainId:c,balanceTokenAddress:C,publishableKey:T,projectName:y,leftIcon:b,onLeftAction:k}){let{colors:h,fonts:p,components:g}=F(),[d,f]=useState(null),[_,R]=useState(false),w=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!_)return;let x=Animated.loop(Animated.sequence([Animated.timing(w,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(w,{toValue:0,duration:700,useNativeDriver:true})]));return x.start(),()=>x.stop()},[_,w]),useEffect(()=>{if(!s||!l||!m||!c||!C||!T){f(null),R(false);return}let x=false;return R(true),La(l,m,c,C,T).then(W=>{if(x)return;let D=W.balance,O=null;D&&(D.amount_usd!=null&&D.amount_usd!==""?O=`$${D.amount_usd}`:O="$0.00"),f(O);}).catch(()=>{x||f(null);}).finally(()=>{x||R(false);}),()=>{x=true;}},[s,l,m,c,C,T]);let S=w.interpolate({inputRange:[0,1],outputRange:[.4,1]});return jsxs(View,{style:wr.header,children:[jsx(View,{style:wr.leftContainer,children:r&&n?jsx(TouchableOpacity,{onPress:n,style:[wr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(_s,{size:20,color:g.header.buttonColor,strokeWidth:2})}):b&&k?jsx(TouchableOpacity,{onPress:k,style:[wr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:b}):jsx(View,{style:wr.spacer})}),jsxs(View,{style:wr.titleContainer,children:[jsxs(View,{style:wr.titleRow,children:[jsx(Text,{style:[wr.title,{color:g.header.titleColor,fontFamily:p.medium}],children:e}),i&&i.count>0&&jsx(View,{style:[wr.titleBadge,{backgroundColor:h.card}],children:jsx(Text,{style:[wr.titleBadgeText,{color:h.foregroundMuted,fontFamily:p.regular}],children:i.count})})]}),t?jsx(Text,{style:[wr.balanceText,{color:h.foregroundMuted,fontFamily:p.regular}],children:t}):null,s&&(_?jsx(Animated.View,{style:[wr.balanceSkeleton,{backgroundColor:h.cardHover,opacity:S}]}):d!=null?jsxs(Text,{style:[wr.balanceText,{color:h.foregroundMuted,fontFamily:p.regular}],children:[y?`${y} `:"","Balance: ",d]}):null)]}),jsx(View,{style:wr.rightContainer,children:o?jsx(TouchableOpacity,{onPress:a,style:[wr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:g.header.buttonColor,strokeWidth:2})}):jsx(View,{style:wr.spacer})})]})}var wr=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},leftContainer:{width:40,alignItems:"flex-start"},rightContainer:{width:40,alignItems:"flex-end"},titleContainer:{flex:1,alignItems:"center"},titleRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},balanceSkeleton:{height:10,width:120,borderRadius:5,marginTop:4},balanceText:{fontSize:14,marginTop:3,textAlign:"center"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function nr({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:a}){let{components:i}=F(),s=a??i.card,l=s.backShadowColor!=="transparent",m={backgroundColor:s.backgroundColor,borderRadius:s.borderRadius,borderWidth:s.borderWidth,borderColor:s.borderColor},c=[Zp.wrapper,t,l&&{marginBottom:s.backShadowSpacing}],C=[m,r];return jsxs(View,{style:c,children:[l&&jsx(View,{style:[Zp.backShadow,{top:s.backShadowOffset.top,left:s.backShadowOffset.left,right:s.backShadowOffset.right,bottom:s.backShadowOffset.bottom,backgroundColor:s.backShadowColor,borderRadius:s.borderRadius}]}),o!=null?jsx(TouchableOpacity$1,{onPress:o,activeOpacity:n,style:C,children:e}):jsx(View,{style:C,children:e})]})}var Zp=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function oa({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card,s=o?[...o].sort((l,m)=>l.position-m.position):[];return jsxs(nr,{cardTokens:i,onPress:e,style:Bo.wrapper,contentStyle:Bo.container,children:[jsxs(View,{style:Bo.leftContent,children:[jsx(View,{style:[Bo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(ac,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Bo.textContainer,children:[jsx(Text,{style:[Bo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Bo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Bo.rightContent,children:jsx(View,{style:Bo.networkIcons,children:s.map((l,m)=>{let c=l.icon_urls.find(C=>C.format==="png")?.url||l.icon_urls.find(C=>C.format==="svg")?.url;return jsx(View,{style:[Bo.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:s.length-m}],children:jsx(En,{uri:re(c),width:20,height:20})},l.name)})})})]})}var Bo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},networkIcons:{flexDirection:"row",alignItems:"center"},networkIconWrapper:{}});function ia({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card;return jsxs(nr,{cardTokens:i,onPress:e,style:en.wrapper,contentStyle:en.container,children:[jsxs(View,{style:en.leftContent,children:[jsx(View,{style:[en.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(Pi,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:en.textContainer,children:[jsx(Text,{style:[en.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[en.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:en.rightContent,children:jsx(View,{style:en.paymentIcons,children:o?.map(s=>{let l=s.icon_urls.find(m=>m.format==="png")?.url||s.icon_urls.find(m=>m.format==="svg")?.url;return jsx(En,{uri:re(l),width:32,height:20,borderRadius:4},s.name)})})})]})}var en=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},paymentIcons:{flexDirection:"row",alignItems:"center",gap:6}});function sa({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:a}=F(),i=a.depositMenu.card;return jsx(nr,{cardTokens:i,onPress:e,style:tn.wrapper,contentStyle:tn.container,children:jsxs(View,{style:tn.leftContent,children:[jsxs(View,{style:[tn.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:[jsx(zr,{size:20,color:i.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[tn.badge,{backgroundColor:i.iconColor,borderRadius:a.badge.borderRadius}],children:jsx(Text,{style:[tn.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:tn.textContainer,children:[jsx(Text,{style:[tn.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[tn.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var tn=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,alignItems:"center",justifyContent:"center",paddingHorizontal:4},badgeText:{color:"#FFFFFF",fontSize:10,fontWeight:"600"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"}});function la({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=F(),a=n.depositMenu.card;return jsxs(nr,{cardTokens:a,onPress:e,style:Ao.wrapper,contentStyle:Ao.container,children:[jsxs(View,{style:Ao.leftContent,children:[jsx(View,{style:[Ao.iconContainer,{borderRadius:a.iconContainerBorderRadius}],children:jsx(Ra,{size:20,color:a.iconColor,strokeWidth:2})}),jsxs(View,{style:Ao.textContainer,children:[jsx(Text,{style:[Ao.title,{color:a.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[Ao.subtitle,{color:a.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:Ao.rightContent,children:jsx(View,{style:Ao.badge,children:jsx(Text,{style:[Ao.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}var Ao=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},badge:{paddingHorizontal:10,paddingVertical:4,borderRadius:6,backgroundColor:"#635BFF"},badgeText:{fontSize:12,fontWeight:"600",color:"#FFFFFF"}});var rm=1e4,om=2500,nm=3e3,im=6e4;function ca(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:a,modalOpenedAt:i,depositWalletId:s,depositExecutions:l,trackedExecutions:m,setDepositExecutions:c,setTrackedExecutions:C,setLatestExecution:T,setShowStatusSheet:y,onDepositSuccess:b,onExecutionsChange:k,onDepositError:h}=e,[p,g]=useState(false),[d,f]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;g(false),t==="auto_ui"&&f(false);let R=setTimeout(()=>{g(true),t==="auto_ui"&&f(true);},rm);return ()=>clearTimeout(R)},[t,r,o]),useEffect(()=>{if(!n||!i)return;let R=new Date(i.getTime()-im),w=setInterval(async()=>{try{let W=[...(await Qo(n,a)).data??[]].sort((O,P)=>{let j=O.created_at?new Date(O.created_at).getTime():0;return (P.created_at?new Date(P.created_at).getTime():0)-j}),D=null;for(let O of W){let P=O.created_at?new Date(O.created_at):null;if(!P||P<=R)continue;let j=m.get(O.id);if(!j){D=O;break}if(["pending","waiting","delayed"].includes(j)&&O.status==="succeeded"){D=O;break}}if(D){let O=D;c(P=>{let j=P.findIndex(q=>q.id===O.id);if(j>=0){let q=[...P];return q[j]=O,q}return [...P,O]}),C(P=>{let j=new Map(P);return j.set(O.id,O.status),j}),T(O),y(!0),O.status==="succeeded"&&b?.({message:"Deposit completed successfully",executionId:O.id}),k?.([...l,O]);}}catch(S){h?.({message:"Failed to check deposit status",error:S});}},om);return ()=>clearInterval(w)},[n,a,i,m,l,k,b,h]),useEffect(()=>{if(!p||!s)return;let R=async()=>{try{await Fa(s,a);}catch{}};R();let w=setInterval(R,nm);return ()=>clearInterval(w)},[p,s,a]),{pollingEnabled:p,showWaitingUi:d,handleIveDeposited:()=>{g(true),f(true);}}}function us({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:a,isDark:i}=F(),s=i?"#1a1a1a":"#ffffff",l=i?"#ffffff":"#000000",m=n||s;return jsxs(View,{style:[am.container,{width:t,height:t}],children:[jsx(Fg,{value:e||"placeholder",size:t,backgroundColor:s,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[am.logoContainer,{width:o+12,height:o+12,backgroundColor:m,borderRadius:(o+12)/2}],children:jsx(En,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var am=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function dm(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function Lg(e){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],o=e.getDate(),n=e.getFullYear(),a=e.getHours(),i=e.getMinutes(),s=a>=12?"pm":"am";a=a%12,a=a||12;let l=i<10?`0${i}`:i;return `${r} ${o}, ${n} at ${a}:${l}${s}`}function ps({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:a,amountUsd:i,onClose:s,borderTopLeftRadius:l,borderTopRightRadius:m}){let{colors:c,fonts:C,components:T}=F(),[y,b]=useState(false),k=t==="pending"||t==="waiting"||t==="delayed",h=t==="succeeded",p=()=>{o&&Linking.openURL(o);},g=()=>{n&&Linking.openURL(n);};return jsx(ft,{visible:e,onClose:s,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:m,children:jsxs(View,{style:At.container,children:[jsx(TouchableOpacity,{style:At.closeButton,onPress:s,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.header.buttonColor,strokeWidth:2})}),jsx(View,{style:At.iconContainer,children:k?jsx(kt,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:re(r)},style:At.tokenIconFill}):jsx(View,{style:[At.tokenIconFill,{backgroundColor:c.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:re(r)},style:At.tokenIconLarge}):jsx(View,{style:[At.tokenIconLarge,{backgroundColor:c.cardHover}]}),jsx(View,{style:[At.statusBadge,{backgroundColor:T.container.iconBackgroundColor}],children:jsx($e,{size:16,color:T.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[At.title,{color:T.container.titleColor,fontFamily:C.semibold}],children:k?"Deposit Processing":"Deposit Complete"}),i!==void 0&&jsxs(Text,{style:[At.amount,{color:T.container.titleColor,fontFamily:C.bold}],children:["$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),a&&jsx(Text,{style:[At.date,{color:T.container.subtitleColor,fontFamily:C.regular}],children:Lg(a)}),jsx(Text,{style:[At.subtitle,{color:T.container.subtitleColor,fontFamily:C.regular}],children:k?"This usually takes less than a minute.":"Your account has been credited successfully!"}),h&&(o||n)&&jsxs(View,{style:At.detailsSection,children:[jsx(View,{style:[At.divider,{backgroundColor:c.border}]}),jsxs(TouchableOpacity,{style:At.detailsToggle,onPress:()=>b(!y),children:[jsx(Text,{style:[At.detailsToggleText,{color:T.container.actionTitle,fontFamily:C.medium}],children:y?"See less":"See more details"}),y?jsx(To,{size:18,color:T.container.actionColor,strokeWidth:2}):jsx(Bt,{size:18,color:T.container.actionColor,strokeWidth:2})]}),y&&jsxs(View,{style:At.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[At.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:p,children:[jsx(Text,{style:[At.txLabel,{color:T.card.titleColor,fontFamily:C.medium}],children:"Deposit tx"}),jsx(Text,{style:[At.txHash,{color:T.card.subtitleColor,fontFamily:C.regular}],children:dm(o)}),jsx(ko,{size:16,color:T.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[At.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:g,children:[jsx(Text,{style:[At.txLabel,{color:T.card.titleColor,fontFamily:C.medium}],children:"Completion tx"}),jsx(Text,{style:[At.txHash,{color:T.card.subtitleColor,fontFamily:C.regular}],children:dm(n)}),jsx(ko,{size:16,color:T.card.actionColor,strokeWidth:2})]})]})]})]})})}var At=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:40},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconContainer:{position:"relative",marginBottom:16},tokenIcon:{width:64,height:64,borderRadius:32},tokenIconLarge:{width:68,height:68,borderRadius:34},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},statusBadge:{position:"absolute",bottom:-2,right:-2,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},title:{fontSize:18,fontWeight:"600",marginBottom:4,textAlign:"center"},amount:{fontSize:28,fontWeight:"700",marginBottom:4,textAlign:"center"},date:{fontSize:13,textAlign:"center",marginBottom:12},detailsSection:{width:"100%",marginTop:16,paddingHorizontal:16},divider:{height:1,width:"100%",opacity:.15},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingVertical:12},detailsToggleText:{fontSize:14,fontWeight:"500"},txButtonsContainer:{width:"100%",gap:10,marginTop:10},txButton:{flexDirection:"row",alignItems:"center",width:"100%",paddingVertical:12,paddingHorizontal:14,borderRadius:10,borderWidth:1,gap:8},txLabel:{fontSize:14,fontWeight:"500"},txHash:{fontSize:14,flex:1,textAlign:"right"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,paddingTop:8},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,paddingHorizontal:20,borderRadius:10,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},successButton:{backgroundColor:"#22C55E"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"},hint:{fontSize:12,marginTop:12,textAlign:"center"}});function wl({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:a,fonts:i,components:s}=F();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[bi.iveDepositedButton,{backgroundColor:a.primary,borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor}],children:jsx(Text,{style:[bi.iveDepositedButtonText,{color:a.primaryForeground??"#FFF",fontFamily:i.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[bi.processingCard,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor,shadowColor:s.card.shadowOpacity>0?s.card.shadowColor:void 0,shadowOffset:s.card.shadowOpacity>0?s.card.shadowOffset:void 0,shadowOpacity:s.card.shadowOpacity,shadowRadius:s.card.shadowRadius,elevation:s.card.elevation}],children:[jsx(View,{style:[bi.detailIcon,{backgroundColor:s.card.iconBackgroundColor,borderRadius:s.card.iconContainerBorderRadius}],children:jsx(lc,{size:14,color:s.card.iconColor,strokeWidth:2})}),jsxs(View,{style:bi.processingCardText,children:[jsx(Text,{style:[bi.processingCardTitle,{color:s.card.titleColor,fontFamily:i.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[bi.processingCardSubtitle,{color:s.card.subtitleColor,fontFamily:i.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var bi=StyleSheet.create({iveDepositedButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginBottom:12},iveDepositedButtonText:{fontSize:16},processingCard:{flexDirection:"row",alignItems:"center",padding:12,marginBottom:12,gap:12},processingCardText:{flex:1,gap:4},processingCardTitle:{fontSize:14},processingCardSubtitle:{fontSize:12,lineHeight:18},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"}});var da=(e,t)=>`${t}:${e}`,Ng=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function kl({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:c="auto_ui",onExecutionsChange:C,onDepositSuccess:T,onDepositError:y,borderTopLeftRadius:b,borderTopRightRadius:k,sheetBorderRadius:h}){let{colors:p,fonts:g,components:d}=F(),f=s&&l?`${s}:${l}`:"solana:mainnet",[_,R]=useState("USDC"),[w,S]=useState(f),[x,W]=useState([]),[D,O]=useState(true),[P,j]=useState([]),[q,ae]=useState(true),[Me,Oe]=useState(false),[X,De]=useState(false),[he,xe]=useState(false),[Ue,we]=useState(false),[ne,Ie]=useState([]),[mt,Ve]=useState(new Map),[lt]=useState(()=>new Date),[He,Ne]=useState(null),[je,Be]=useState(false),[J,ce]=useState(null),[nt,it]=useState(false),ve=new Map;P.forEach(E=>{E.chains.forEach(te=>{let ye=`${te.chain_type}:${te.chain_id}`;ve.has(ye)||ve.set(ye,te);});});let be=Array.from(ve.values()),ie=Ng(w),Qt=be.find(E=>E.chain_type===ie.chainType&&E.chain_id===ie.chainId)?.chain_type||"ethereum",ue=qo(x,Qt),le=ue?.address||"",Ce=useRef(false);useEffect(()=>{async function E(){try{ae(!0),Ne(null);let ye=await Gn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(j(ye.data),ye.data.length>0&&!Ce.current){Ce.current=!0;let me,gt;if(s&&l)if(m)for(let V of ye.data){let Or=V.chains.find(z=>z.chain_type===s&&z.chain_id===l&&z.token_address.toLowerCase()===m.toLowerCase());if(Or){me=V,gt=Or;break}}else for(let V of ye.data){let Or=V.chains.find(z=>z.chain_type===s&&z.chain_id===l);if(Or){me=V,gt=Or;break}}if(!me&&a)for(let V of ye.data){let Or=V.chains.find(z=>z.token_address.toLowerCase()===a.toLowerCase());if(Or){me=V,gt=Or;break}}me||(me=ye.data.find(V=>V.symbol==="USDC"),me&&me.chains.length>0&&(gt=me.chains[0])),me||(me=ye.data.find(V=>V.symbol==="USDT"),me&&me.chains.length>0&&(gt=me.chains[0])),me||(me=ye.data[0],me.chains.length>0&&(gt=me.chains[0])),me&&R(me.symbol),gt&&S(da(gt.chain_id,gt.chain_type));}}catch(te){console.error("Error fetching supported tokens:",te),Ne("Failed to load supported tokens"),y?.({message:"Failed to load supported tokens",error:te});}finally{ae(false);}}E();},[t,y,s,l,m,a,n,o]),useEffect(()=>{async function E(){try{O(!0),Ne(null);let te=await $o({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);W(te.data);}catch(te){console.error("Error fetching wallets:",te),Ne("Failed to load wallets"),y?.({message:"Failed to load wallets",error:te});}finally{O(false);}}E();},[e,r,o,n,a,t,y]);let wt=ue?.id??"",{showWaitingUi:tt,handleIveDeposited:pe}=ca({depositConfirmationMode:c,depositAddress:le,chain:w,externalUserId:e,publishableKey:t,modalOpenedAt:lt,depositWalletId:wt,depositExecutions:ne,trackedExecutions:mt,setDepositExecutions:Ie,setTrackedExecutions:Ve,setLatestExecution:ce,setShowStatusSheet:Be,onDepositSuccess:T,onExecutionsChange:C,onDepositError:y});useEffect(()=>{if(!P.length)return;let E=P.find(ye=>ye.symbol===_);if(!E||E.chains.length===0)return;if(!E.chains.some(ye=>da(ye.chain_id,ye.chain_type)===w)){let ye=E.chains[0];S(da(ye.chain_id,ye.chain_type));}},[_,P,w]);let Qe=P.find(E=>E.symbol===_),ir=Qe?.chains||[],xt=ir.find(E=>da(E.chain_id,E.chain_type)===w),Pr=async()=>{if(le)try{Clipboard.setString(le),Oe(!0),setTimeout(()=>Oe(!1),2e3);}catch(E){console.error("Failed to copy:",E);}},Fr=xt?.estimated_price_impact_percent??0,U=xt?.max_slippage_percent??.25,Q=xt?.minimum_deposit_amount_usd??3;if(q)return jsxs(View,{style:L.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:p.primary}),jsx(Text,{style:[L.loadingText,{color:p.foregroundMuted,fontFamily:g.regular}],children:"Loading currencies..."})]});if(He&&P.length===0)return jsxs(View,{style:L.errorContainer,children:[jsx(Text,{style:[L.errorText,{color:p.error,fontFamily:g.regular}],children:He}),jsx(Text,{style:[L.errorHint,{color:p.foregroundMuted,fontFamily:g.regular}],children:"Please check your network connection and try again."})]});let se=()=>jsxs(ft,{visible:he,onClose:()=>xe(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.tokenSelector?.borderTopLeftRadius??b,borderTopRightRadius:h?.tokenSelector?.borderTopRightRadius??k,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:p.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:g.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>xe(false),style:L.sheetCloseButton,children:jsx(st,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(ht,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:P.map(E=>jsxs(TouchableOpacity$1,{onPress:()=>{R(E.symbol),xe(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:_===E.symbol?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:re(Se(E,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:E.symbol}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:g.regular}],children:[E.chains.length," network",E.chains.length!==1?"s":""," available"]})]}),_===E.symbol&&jsx($e,{size:20,color:p.primary,strokeWidth:2})]},E.symbol))})]}),ze=()=>jsxs(ft,{visible:Ue,onClose:()=>we(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.chainSelector?.borderTopLeftRadius??b,borderTopRightRadius:h?.chainSelector?.borderTopRightRadius??k,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:p.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:g.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>we(false),style:L.sheetCloseButton,children:jsx(st,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(ht,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:ir.map(E=>{let te=da(E.chain_id,E.chain_type),ye=w===te;return jsxs(TouchableOpacity$1,{onPress:()=>{S(te),we(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:ye?d.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:re(Se(E,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:E.chain_name}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:d.card.subtitleColor,fontFamily:g.regular}],children:["Min deposit: $",E.minimum_deposit_amount_usd]})]}),ye&&jsx($e,{size:20,color:p.primary,strokeWidth:2})]},te)})})]});return jsxs(View,{style:L.container,children:[jsxs(View,{style:L.selectorSection,children:[jsx(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:g.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>xe(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[Qe&&jsx(Image,{source:{uri:re(Se(Qe,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:g.medium}],children:_}),jsx(Bt,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:L.selectorSection,children:[jsxs(Text,{style:[L.selectorLabel,{color:d.card.labelColor,fontFamily:g.regular}],children:["Network"," ",jsxs(Text,{style:[L.minDeposit,{fontFamily:g.regular}],children:["($",Q," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>we(true),style:[L.selector,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[xt&&jsx(Image,{source:{uri:re(Se(xt,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:d.card.titleColor,fontFamily:g.medium}],numberOfLines:1,children:xt?.chain_name||"Select network"}),jsx(Bt,{size:16,color:d.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:L.qrContainer,children:jsx(View,{style:[L.qrWrapper,{backgroundColor:p.background,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth>0?d.card.borderWidth:1,borderColor:d.card.borderColor}],children:D?jsxs(View,{style:L.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:p.primary}),jsx(Text,{style:[L.loadingText,{color:p.foregroundMuted,fontFamily:g.regular}],children:"Loading..."})]}):le?jsx(us,{value:le,size:160,logoUri:re(Se(xt,"png")||Gt("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:L.qrLoading,children:jsx(Text,{style:[L.errorText,{color:p.error,fontFamily:g.regular}],children:"No address available"})})})}),jsxs(View,{style:L.addressSection,children:[jsxs(View,{style:L.addressHeader,children:[jsx(Text,{style:[L.addressLabel,{color:d.card.labelColor,fontFamily:g.medium}],children:"Deposit Address"}),Me&&jsxs(View,{style:L.copiedIndicator,children:[jsx($e,{size:14,color:p.success,strokeWidth:2}),jsx(Text,{style:[L.copiedText,{color:p.success,fontFamily:g.regular}],children:"Copied"})]})]}),jsxs(nr,{cardTokens:d.transferCrypto.depositAddress.card,onPress:!D&&le?Pr:void 0,contentStyle:L.addressBox,children:[jsx(Text,{style:[L.addressText,{color:d.card.titleColor,fontFamily:g.regular}],numberOfLines:2,children:D?"Loading...":le||"No address available"}),jsx(View,{style:L.addressCopyIcon,children:jsx(No,{size:16,color:d.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[L.detailsCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>De(!X),style:L.detailsHeader,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:L.chevronContainer,children:X?jsx(To,{size:16,color:d.card.actionColor,strokeWidth:2}):jsx(Bt,{size:16,color:d.card.actionColor,strokeWidth:2})})]}),X&&jsxs(View,{style:L.detailsContent,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:["Price impact: ",Fr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>it(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:["Slippage: Auto \u2022 ",U.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>it(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(xa,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:d.card.titleColor,fontFamily:g.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(wl,{depositConfirmationMode:c,depositAddress:le,showWaitingUi:tt,latestExecution:J,onIveDeposited:pe}),jsx(TouchableOpacity$1,{style:L.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[L.termsText,{color:p.primary,fontFamily:g.regular}],children:"Terms apply"})}),se(),ze(),jsxs(ft,{visible:nt,onClose:()=>it(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:h?.infoSheet?.borderTopLeftRadius??b,borderTopRightRadius:h?.infoSheet?.borderTopRightRadius??k,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:p.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:d.header.titleColor,fontFamily:g.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>it(false),style:L.sheetCloseButton,children:jsx(st,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:L.infoSheetContent,children:[jsxs(View,{style:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(gn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:"Price Impact"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:g.medium}],children:[Fr.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.card.descriptionColor,fontFamily:g.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[L.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(yn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:d.card.titleColor,fontFamily:g.medium}],children:"Max Slippage"}),jsxs(Text,{style:[L.infoCardValue,{color:d.card.titleColor,fontFamily:g.medium}],children:[U.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:d.card.descriptionColor,fontFamily:g.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),J&&jsx(ps,{visible:je,status:J.status,tokenIconUrl:J.destination_token_metadata?.icon_urls?.find(E=>E.format==="png")?.url||J.destination_token_metadata?.icon_url||Se(Qe,"png"),explorerUrl:J.explorer_url,completionExplorerUrl:J.destination_explorer_url,date:J.created_at?new Date(J.created_at):void 0,amountUsd:J.source_amount_usd?parseFloat(J.source_amount_usd):void 0,onClose:()=>Be(false),borderTopLeftRadius:h?.depositStatus?.borderTopLeftRadius??b,borderTopRightRadius:h?.depositStatus?.borderTopRightRadius??k})]})}var L=StyleSheet.create({container:{flex:1,padding:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:13,marginBottom:8},minDeposit:{fontSize:10},selector:{flexDirection:"row",alignItems:"center",gap:10,padding:12,borderRadius:12},selectorIcon:{width:24,height:24,borderRadius:12},selectorText:{flex:1,fontSize:14,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:16},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:13},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},spacer:{flex:1},termsContainer:{alignItems:"center"},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},sheetList:{flex:1,paddingTop:8},sheetListContent:{paddingBottom:56},sheetItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,marginHorizontal:8,borderRadius:12,gap:12},sheetItemIcon:{width:40,height:40,borderRadius:20},sheetItemText:{flex:1},sheetItemTitle:{fontSize:16,fontWeight:"500"},sheetItemSubtitle:{fontSize:12,marginTop:2},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});function Tl({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:a}=F();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[Ci.container,{backgroundColor:a.card.backgroundColor,borderRadius:a.list.rowBorderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:Ci.leftContent,children:[jsx(View,{style:[Ci.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:re(Se(e,"png"))},style:Ci.icon})}),jsxs(View,{style:Ci.textContainer,children:[jsx(Text,{style:[Ci.name,{color:a.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[Ci.code,{color:a.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx($e,{size:16,color:o.primary,strokeWidth:2})]})}var Ci=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,marginHorizontal:8,marginVertical:4},leftContent:{flexDirection:"row",alignItems:"center",gap:12},iconContainer:{width:40,height:40,borderRadius:20,overflow:"hidden",alignItems:"center",justifyContent:"center"},icon:{width:40,height:40,borderRadius:20},textContainer:{gap:2},name:{fontSize:14,fontWeight:"400"},code:{fontSize:12,fontWeight:"300"}});function pa({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:a}=F();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:fm.headerContainer,children:jsx(Text,{style:[fm.title,{color:a.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(i=>jsx(Tl,{currency:i,isSelected:r.toLowerCase()===i.currency_code.toLowerCase(),onSelect:o},i.currency_code))]})}var fm=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function _l({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:c}=F(),[C,T]=useState(""),y=o.map(f=>r.find(_=>_.currency_code.toLowerCase()===f.toLowerCase())).filter(f=>f!==void 0),b=r.filter(f=>!o.includes(f.currency_code.toLowerCase())),k=f=>{if(!C)return f;let _=C.toLowerCase();return f.filter(R=>R.name.toLowerCase().includes(_)||R.currency_code.toLowerCase().includes(_))},h=k(y),p=k(b),g=f=>{a(f),t(false),T("");},d=()=>{t(false),T("");};return jsxs(ft,{visible:e,onClose:d,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsx(Ir,{title:"Currency",showBack:false,onClose:d}),jsx(View,{style:wi.searchContainer,children:jsx(TextInput,{style:[wi.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:m.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],value:C,onChangeText:T,placeholder:"Search",placeholderTextColor:c.search.placeholderColor})}),jsx(ht,{style:wi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:wi.listContent,children:[jsx(pa,{title:"Popular currencies",currencies:h,selectedCurrency:n,onSelect:g}),h.length>0&&p.length>0&&jsx(View,{style:wi.sectionSpacer}),jsx(pa,{title:"All currencies",currencies:p,selectedCurrency:n,onSelect:g}),h.length===0&&p.length===0&&jsx(View,{style:wi.noResultsContainer,children:jsx(Text,{style:[wi.noResultsText,{color:c.container.subtitleColor,fontFamily:m.regular}],children:"No currencies found"})})]})})]})}var wi=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:18,paddingBottom:12},searchInput:{padding:16,fontSize:14},listContainer:{flex:1,paddingHorizontal:12},listContent:{paddingBottom:72},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function Od(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e.toUpperCase(),minimumFractionDigits:0,maximumFractionDigits:0}).format(0).replace(/\d/g,"").trim()}catch{return e.toUpperCase()}}function vl({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:a,destinationChainType:i,destinationChainId:s,destinationTokenAddress:l,onDepositSuccess:m,onDepositError:c,borderTopLeftRadius:C,borderTopRightRadius:T,sheetBorderRadius:y}){let{colors:b,fonts:k,components:h}=F(),[p,g]=useState(""),[d,f]=useState("usd"),[_,R]=useState(false),[w,S]=useState(false),[x,W]=useState([]),[D,O]=useState(false),[P,j]=useState(null),[q,ae]=useState(null),[Me,Oe]=useState("amount"),[X,De]=useState(null),[he,xe]=useState(true),[Ue,we]=useState(null),[ne,Ie]=useState(false),mt=useRef(null),Ve=useRef(false);useEffect(()=>{mt.current=X;},[X]),useEffect(()=>{Ve.current=ne;},[ne]);let[lt,He]=useState([]),[Ne,je]=useState(true),[Be,J]=useState(60),[ce,nt]=useState([]),[it,ve]=useState([]),[be,ie]=useState(null),[de,Qt]=useState(null),[ue,le]=useState(true),[Ce,wt]=useState(null),[tt,pe]=useState(false),[Qe,ir]=useState(null),[xt,Pr]=useState(false),[Fr,U]=useState(false),[Q,se]=useState(false),[ze,E]=useState(null),te=r??Me,ye=useRef(null),me=ce.find(K=>K.currency_code.toLowerCase()===d.toLowerCase()),gt=useCallback(K=>{Oe(K),K==="quotes"?o?.(K,x.length):o?.(K);},[x.length,o]);useEffect(()=>{async function K(){try{let ge=await Ls();Qt(ge);}catch(ge){console.error("Error fetching user IP:",ge);}finally{le(false);}}K();},[]),useEffect(()=>{async function K(){try{let ge=await $o({external_user_id:e,recipient_address:a,destination_chain_type:i,destination_chain_id:s,destination_token_address:l},t);He(ge.data);}catch(ge){console.error("Error fetching wallets:",ge),j("Failed to load wallet addresses");}finally{je(false);}}K();},[e,a,i,s,l,t]);let V=n||be?.symbol.toUpperCase()||"USDC",Or=Li(be?.icon_urls,"png")||be?.icon_url,z=Li(be?.chain_icon_urls,"png")||be?.chain_icon_url;useEffect(()=>{async function K(){try{let ge=await bc(t);nt(ge.data),ve(ge.preferred||[]);}catch(ge){console.error("Error fetching fiat currencies:",ge);}}K();},[t]),useEffect(()=>{if(_||ce.length===0||!de?.alpha2)return;let K=de.alpha2.toUpperCase(),ge=ce.find(Lt=>Lt.country_codes.includes(K));if(ge)f(ge.currency_code.toLowerCase()),!p&&!w&&g(String(ge.default_amount??100));else if(!p&&!w){let Lt=ce.find(po=>po.currency_code.toLowerCase()==="usd");Lt&&g(String(Lt.default_amount??100));}},[ce,de,_,p,w]),useEffect(()=>{if(ce.length!==0){if(ye.current!==null&&ye.current!==d){let K=ce.find(ge=>ge.currency_code.toLowerCase()===d.toLowerCase());K&&g(String(K.default_amount??100));}ye.current=d;}},[d,ce]),useEffect(()=>{async function K(){try{let ge=await fc({chain_type:i||"",chain_id:s||"",token_address:l||""},t);ie(ge);}catch(ge){console.error("Error fetching supported tokens:",ge);}}K();},[i,s,l,t]),useEffect(()=>{async function K(){if(!(!l||!s||!i)&&!ue){pe(true);try{let ge=await yc({country_code:de?.alpha2?.toUpperCase()||"US",subdivision_code:de?.state||void 0,token_address:l,chain_id:s,chain_type:i},t);wt(ge);}catch(ge){console.error("Error fetching default onramp token:",ge);}finally{pe(false);}}}K();},[l,s,i,de,ue,t]),useEffect(()=>{let K=parseFloat(p);if(isNaN(K)||K<=0){W([]),ae(null);return}if(!Ce||tt){W([]),De(null);return}let ge=ce.find(po=>po.currency_code.toLowerCase()===d.toLowerCase());if(ge){if(K<ge.minimum_amount){W([]),De(null),ae(`Minimum amount is ${Od(d)}${ge.minimum_amount.toLocaleString()}`);return}if(K>ge.maximum_amount){W([]),De(null),ae(`Maximum amount is ${Od(d)}${ge.maximum_amount.toLocaleString()}`);return}}ae(null);let Lt=setTimeout(()=>{Ft(K);},500);return ()=>clearTimeout(Lt)},[p,d,t,Ce,tt,ce]);let Ft=async K=>{if(!Ce){j("Loading token information...");return}O(true),j(null);try{let ge={country_code:de?.alpha2?.toUpperCase()||"US",source_amount:K.toString(),source_currency:d.toLowerCase(),destination_currency:Ce.destination_currency,destination_network:Ce.destination_network,subdivision_code:de?.state||void 0},Lt=await hc(ge,t);W(Lt.data);let po=Ve.current,ks=mt.current;if(po&&ks){let mo=Lt.data.find(fn=>fn.service_provider===ks.service_provider);if(mo){if(De(mo),Lt.data.length>0){let fn=Lt.data[0];Ue||we(fn.service_provider),xe(mo.service_provider===Ue);}}else if(Lt.data.length>0){let fn=Lt.data[0];De(fn),we(fn.service_provider),xe(!0),Ie(!1);}}else if(Lt.data.length>0){let mo=Lt.data[0];De(mo),we(mo.service_provider),xe(!0);}J(60);}catch(ge){console.error("Failed to fetch quotes:",ge),j("Failed to fetch quotes. Please try again."),W([]);}finally{O(false);}};useEffect(()=>{if(x.length===0)return;let K=setInterval(()=>{J(ge=>{if(ge<=1){let Lt=parseFloat(p);return !isNaN(Lt)&&Lt>0&&Ft(Lt),60}return ge-1});},1e3);return ()=>clearInterval(K)},[x.length,p]);let St=K=>{(/^\d*\.?\d{0,2}$/.test(K)||K==="")&&(g(K),S(true));},Mr=K=>{g(K.toString()),S(true);},Xt=async()=>{if(X&&Ce)try{let K=Ce.destination_token_metadata.chain_type,ge=qo(lt,K);if(!ge?.address){j("Wallet address not available");return}let Lt={service_provider:X.service_provider,country_code:X.country_code?.toUpperCase()||de?.alpha2?.toUpperCase()||"US",source_currency:X.source_currency,source_amount:p,destination_currency:X.destination_currency,destination_network:X.destination_network,wallet_address:ge.address,subdivision_code:de?.state||void 0},po=await gc(Lt,t);ir({provider:X,sourceCurrency:d,sourceAmount:p,sessionUrl:po.url}),E(po.url),se(!0);}catch(K){console.error("Failed to create session:",K),j("Failed to start payment flow"),c?.({message:"Failed to start payment flow",error:K});}},Ii=Od(d),uo=()=>{se(false),gt("onramp"),m?.({message:"Payment flow completed"});},Ho=()=>jsx(oy,{visible:Q,onClose:uo,url:ze,providerName:X?.service_provider_display_name||"Complete Payment",colors:b,fonts:k,borderTopLeftRadius:y?.webView?.borderTopLeftRadius??C,borderTopRightRadius:y?.webView?.borderTopRightRadius??T});return te==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:$.amountViewContainer,children:[jsxs(ht,{style:$.scrollContainer,contentContainerStyle:$.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:$.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>Pr(true),style:[$.currencyButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.input.borderRadius,borderWidth:h.input.borderWidth,borderColor:h.input.borderColor}],children:[me&&jsx(Image,{source:{uri:re(Se(me,"png"))},style:$.currencyIcon}),jsx(Text,{style:[$.currencyText,{color:h.card.titleColor,fontFamily:k.medium}],children:d.toUpperCase()}),jsx(Bt,{size:16,color:h.card.actionColor,strokeWidth:2})]})}),jsx(_l,{open:xt,onOpenChange:Pr,currencies:ce,preferredCurrencyCodes:it,selectedCurrency:d,onSelectCurrency:K=>{f(K.toLowerCase()),R(true);},borderTopLeftRadius:y?.currencyModal?.borderTopLeftRadius??C,borderTopRightRadius:y?.currencyModal?.borderTopRightRadius??T}),jsx(View,{style:$.amountContainer,children:jsxs(View,{style:$.amountInputRow,children:[jsx(Text,{style:[$.currencySymbol,{color:h.container.titleColor,fontFamily:k.medium}],children:Ii}),jsx(TextInput,{style:[$.amountInput,{color:h.container.titleColor,fontFamily:k.medium}],value:p,onChangeText:St,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:b.foregroundMuted})]})}),me?.suggested_amounts&&me.suggested_amounts.length>0&&jsx(View,{style:$.quickAmounts,children:me.suggested_amounts.map(K=>jsx(TouchableOpacity$1,{onPress:()=>Mr(K),style:[$.quickAmountButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.button.borderRadius,borderWidth:parseFloat(p)===K?2:h.button.borderWidth,borderColor:parseFloat(p)===K?b.primary:h.button.borderColor}],children:jsxs(Text,{style:[$.quickAmountText,{color:h.card.titleColor,fontFamily:k.medium}],children:[Ii,K.toLocaleString()]})},K))}),q&&jsx(Text,{style:[$.validationError,{color:b.error,fontFamily:k.regular}],children:q}),jsxs(View,{style:$.providerSection,children:[jsxs(View,{style:$.providerHeader,children:[jsx(Text,{style:[$.providerLabel,{color:h.card.labelColor,fontFamily:k.medium}],children:"Provider"}),x.length>0&&!D&&jsxs(Text,{style:[$.refreshText,{color:h.card.labelRightColor,fontFamily:k.regular}],children:["Refreshing in ",Be,"s"]})]}),jsx(nr,{cardTokens:h.depositCard.quoteProvider.card,onPress:D||x.length===0?void 0:()=>U(true),contentStyle:StyleSheet.flatten([$.providerButton,(D||x.length===0)&&$.disabled]),children:D?jsxs(View,{style:$.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),jsx(Text,{style:[$.loadingText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:"Finding best rates..."})]}):X?jsxs(View,{style:$.providerContent,children:[jsxs(View,{style:$.providerInfo,children:[he&&jsx(Text,{style:[$.autoPickedText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:"Auto-picked for you"}),jsxs(View,{style:$.providerRow,children:[jsx(Image,{source:{uri:re(Oa(X.icon_urls,"png",X.icon_url))},style:$.providerIconImage},`provider-${X.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[$.providerName,{color:h.card.titleColor,fontFamily:k.medium}],children:X.service_provider_display_name}),jsxs(Text,{style:[$.bestPriceText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:[X.destination_amount.toFixed(2)," ",V]})]})]})]}),jsx(Tr,{size:20,color:h.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[$.noProviderText,{color:h.container.subtitleColor,fontFamily:k.regular}],children:parseFloat(p)>0?"No providers available":"Enter an amount to see providers"})}),P&&jsx(Text,{style:[$.errorText,{color:b.error,fontFamily:k.regular}],children:P})]}),jsxs(ft,{visible:Fr,onClose:()=>U(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:y?.providerModal?.borderTopLeftRadius??C,borderTopRightRadius:y?.providerModal?.borderTopRightRadius??T,children:[jsx(Ir,{title:"Select Provider",showBack:false,onClose:()=>U(false)}),jsx(ht,{style:$.providerModalList,contentContainerStyle:$.providerModalListContent,showsVerticalScrollIndicator:false,children:jsx(View,{style:$.quotesList,children:x.map(K=>{let ge=X?.service_provider===K.service_provider;return jsxs(nr,{cardTokens:h.depositCard.quoteProvider.card,onPress:()=>{De(K),Ie(true),xe(K.service_provider===Ue),U(false);},contentStyle:StyleSheet.flatten([$.quoteItem,ge&&{borderWidth:2,borderColor:b.primary}]),children:[jsxs(View,{style:$.quoteLeft,children:[jsx(Image,{source:{uri:re(Oa(K.icon_urls,"png",K.icon_url))},style:$.providerIconImage}),jsx(View,{children:jsx(Text,{style:[$.quoteName,{color:h.card.titleColor,fontFamily:k.medium}],children:K.service_provider_display_name})})]}),jsxs(View,{style:$.quoteRight,children:[jsxs(Text,{style:[$.quoteAmount,{color:h.card.textRightColor,fontFamily:k.medium}],children:[K.destination_amount.toFixed(2)," ",V]}),jsxs(Text,{style:[$.quoteSource,{color:h.card.subtextRightColor,fontFamily:k.regular}],children:["Fee: ",Ii,K.total_fee.toFixed(2)]})]})]},K.service_provider)})})})]})]}),jsx(View,{style:[$.continueButtonContainer,{backgroundColor:b.background}],children:jsx(View,{style:{opacity:D||Ne||!X||parseFloat(p)<=0?.5:1},children:jsx(TouchableOpacity$1,{onPress:Xt,disabled:D||Ne||!X||parseFloat(p)<=0,style:[$.continueButton,{backgroundColor:h.container.buttonColor,borderRadius:h.button.borderRadius,borderWidth:h.button.borderWidth,borderColor:h.button.borderColor}],children:jsx(Text,{style:[$.continueButtonText,{color:h.container.buttonTitleColor,fontFamily:k.medium}],children:Ne?"Loading...":"Continue"})})})})]}),Ho()]}):te==="onramp"&&Qe?jsxs(View,{style:$.onrampContainer,children:[jsx(Image,{source:{uri:re(Oa(Qe.provider.icon_urls,"png",Qe.provider.icon_url))},style:$.onrampProviderIcon}),jsxs(Text,{style:[$.onrampTitle,{color:h.container.titleColor,fontFamily:k.medium}],children:["Complete transaction with ",Qe.provider.service_provider_display_name]}),jsx(Text,{style:[$.onrampSubtitle,{color:h.container.subtitleColor,fontFamily:k.regular}],children:"You can close this modal."}),jsxs(View,{style:[$.flowDiagram,{backgroundColor:h.card.backgroundColor}],children:[jsxs(View,{style:$.flowStep,children:[jsx(Image,{source:{uri:Gt(`/icons/currencies/png/${Qe.sourceCurrency.toLowerCase()}.png`)},style:$.flowIconImage}),jsx(Text,{style:[$.flowLabel,{color:h.card.subtitleColor,fontFamily:k.regular}],children:"You use"}),jsx(Text,{style:[$.flowValue,{color:h.card.titleColor,fontFamily:k.medium}],children:Qe.sourceCurrency.toUpperCase()})]}),jsx(Tr,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:$.flowStep,children:[jsxs(View,{style:$.flowIconWithBadge,children:[jsx(Image,{source:{uri:Li(Ce?.destination_token_metadata?.icon_urls,"png")||Ce?.destination_token_metadata?.icon_url||Gt("/icons/tokens/png/usdc.png")},style:$.flowIconImageNoBadge}),jsx(Image,{source:{uri:Li(Ce?.destination_token_metadata?.chain?.icon_urls,"png")||Ce?.destination_token_metadata?.chain?.icon_url||Gt("/icons/networks/png/polygon.png")},style:[$.flowNetworkBadge,{borderColor:b.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[$.flowLabel,{color:h.card.subtitleColor,fontFamily:k.regular}],children:"You buy"}),jsx(Text,{style:[$.flowValue,{color:h.card.titleColor,fontFamily:k.medium}],children:"USDC"})]}),jsx(Tr,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:$.flowStep,children:[jsxs(View,{style:$.flowIconWithBadge,children:[jsx(Image,{source:{uri:Or||Gt("/icons/tokens/png/usdc.png")},style:$.flowIconImageNoBadge}),jsx(Image,{source:{uri:z||Gt("/icons/networks/png/polygon.png")},style:[$.flowNetworkBadge,{borderColor:b.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[$.flowLabel,{color:h.card.subtitleColor,fontFamily:k.regular}],children:"You receive"}),jsx(Text,{style:[$.flowValue,{color:h.card.titleColor,fontFamily:k.medium}],children:V})]})]}),jsx(View,{style:[$.onrampInfoBox,{backgroundColor:h.card.backgroundColor,borderRadius:h.card.borderRadius,borderWidth:h.card.borderWidth,borderColor:h.card.borderColor}],children:jsx(Text,{style:[$.onrampInfoText,{color:h.card.descriptionColor,fontFamily:k.regular}],children:"The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."})})]}):null}function oy({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:a,borderTopLeftRadius:i,borderTopRightRadius:s}){return jsxs(ft,{visible:e,onClose:t,closeOnBackdropPress:false,enablePanDownToClose:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:Si.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:Si.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx($e,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[Si.headerTitle,{color:n.foreground,fontFamily:a.medium}],children:o}),jsx(View,{style:Si.headerSpacer})]}),r&&jsx(View,{style:Si.container,children:jsx(WebView,{source:{uri:r},style:Si.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:Si.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var Si=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},headerButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},headerSpacer:{width:28,height:28},container:{flex:1},webView:{flex:1},loading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"}}),$=StyleSheet.create({amountViewContainer:{flex:1},scrollContainer:{flex:1},scrollContent:{padding:16,paddingBottom:16},currencySelector:{alignItems:"center",marginBottom:16},currencyButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8},currencyText:{fontSize:14,fontWeight:"500"},currencyIcon:{width:24,height:24,borderRadius:12},amountContainer:{alignItems:"center",marginBottom:24},amountInputRow:{flexDirection:"row",alignItems:"center",marginBottom:8},currencySymbol:{fontSize:48,fontWeight:"300"},amountInput:{fontSize:48,fontWeight:"300",minWidth:50},usdcPreview:{fontSize:14},quickAmounts:{flexDirection:"row",justifyContent:"center",gap:12,marginBottom:24},quickAmountButton:{paddingHorizontal:20,paddingVertical:10},quickAmountText:{fontSize:14,fontWeight:"500"},validationError:{fontSize:12,textAlign:"center",marginTop:12,paddingHorizontal:16},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16},disabled:{opacity:.5},providerLoading:{flexDirection:"row",alignItems:"center",gap:12},loadingText:{fontSize:14},providerContent:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},providerInfo:{flex:1},autoPickedText:{fontSize:12,marginBottom:6},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerIconPlaceholder:{width:32,height:32,borderRadius:8},providerIconImage:{width:32,height:32,borderRadius:8},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:48},continueButton:{paddingVertical:16,alignItems:"center"},continueButtonText:{fontSize:16,fontWeight:"600"},webViewHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},webViewHeaderButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},webViewHeaderTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},webViewHeaderSpacer:{width:28,height:28},webViewContainer:{flex:1},webView:{flex:1},webViewLoading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},providerModalList:{flex:1,paddingHorizontal:12,marginTop:8},providerModalListContent:{paddingBottom:72},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12},quoteLeft:{flexDirection:"row",alignItems:"center",gap:12},quoteIcon:{width:40,height:40,borderRadius:20},quoteName:{fontSize:14,fontWeight:"500"},quoteRight:{alignItems:"flex-end"},quoteAmount:{fontSize:14,fontWeight:"500"},quoteSource:{fontSize:12},onrampContainer:{flex:1,padding:16,alignItems:"center",paddingTop:24},onrampProviderIcon:{width:64,height:64,borderRadius:16},onrampTitle:{fontSize:18,fontWeight:"600",textAlign:"center",marginTop:20,marginBottom:8,paddingHorizontal:16},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:20,paddingHorizontal:24,borderRadius:12,width:"100%"},flowIconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},flowIconImageNoBadge:{width:24,height:24,borderRadius:12},flowNetworkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,width:"100%"},onrampInfoText:{fontSize:13,lineHeight:20},flowStep:{alignItems:"center"},flowIcon:{width:28,height:28,borderRadius:14,marginBottom:4},flowIconImage:{width:24,height:24,borderRadius:12,marginBottom:4},flowLabel:{fontSize:10},flowValue:{fontSize:14,fontWeight:"500"}});function ay(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function ly(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Ol({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=F(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=re(Se(e.destination_token_metadata,"png")||Gt("/icons/tokens/png/usdc.png")),m=i?"Deposit Processing":"Deposit Completed",c=ay(e.created_at||new Date().toISOString()),C=ly(e.source_amount_usd);return jsxs(nr,{cardTokens:a,onPress:t,contentStyle:sn.container,children:[jsxs(View,{style:sn.iconContainer,children:[jsx(Image,{source:{uri:l},style:sn.tokenIcon}),jsx(View,{style:[sn.statusBadge,{backgroundColor:i?r.warning:r.success,borderColor:a.backgroundColor}],children:i?jsx(_a,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx($e,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:sn.textContainer,children:[jsx(Text,{style:[sn.title,{color:a.titleColor,fontFamily:o.medium}],children:m}),jsx(Text,{style:[sn.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:c})]}),jsxs(View,{style:sn.rightContainer,children:[jsx(Text,{style:[sn.amount,{color:a.textRightColor,fontFamily:o.medium}],children:C}),jsx(Tr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var sn=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16,fontWeight:"500"},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16,fontWeight:"500"}});function bm(e,t){let r={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||r[e]||e:r[e]||e}function Cm(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function dy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var wm=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function Sm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function uy(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function py({count:e=4}){let{colors:t,components:r}=F(),o=useRef(new Animated.Value(.5)).current,n=r.depositTracker.executionRow.card,a=t.cardHover;return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[o]),jsx(View,{style:ki.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[ki.row,{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius??12,borderWidth:n.borderWidth,borderColor:n.borderColor}],children:[jsx(Animated.View,{style:[ki.icon,{backgroundColor:a,opacity:o}]}),jsxs(View,{style:ki.textBlock,children:[jsx(Animated.View,{style:[ki.titleBar,{backgroundColor:a,opacity:o}]}),jsx(Animated.View,{style:[ki.subtitleBar,{backgroundColor:a,opacity:o}]})]}),jsx(Animated.View,{style:[ki.amountBar,{backgroundColor:a,opacity:o}]})]},s))})}var ki=StyleSheet.create({list:{paddingTop:16,paddingHorizontal:16,gap:12},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},icon:{width:40,height:40,borderRadius:20,marginRight:12},textBlock:{flex:1,gap:6},titleBar:{height:14,width:"65%",borderRadius:7},subtitleBar:{height:11,width:"45%",borderRadius:5.5},amountBar:{height:14,width:50,borderRadius:7,marginLeft:12}});function Ld({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{colors:a,fonts:i,components:s}=F(),[l,m]=useState(r),[c,C]=useState(false),[T,y]=useState(null),[b,k]=useState(false),h=useRef(null);useEffect(()=>{if(!e||!o)return;let w=async()=>{C(true);try{let W=[...(await Qo(o,n)).data].sort((D,O)=>{let P=D.created_at?new Date(D.created_at).getTime():0;return (O.created_at?new Date(O.created_at).getTime():0)-P});m(W);}catch(x){console.error("Failed to fetch executions:",x),m(r);}finally{C(false);}};w();let S=setInterval(w,1e4);return ()=>clearInterval(S)},[e,o,n,r]),useEffect(()=>{r.length>0&&m(w=>{let S=new Set(w.map(W=>W.id)),x=r.filter(W=>!S.has(W.id));return x.length>0?[...x,...w]:w});},[r]),useEffect(()=>{e||y(null);},[e]);let p=w=>{y(w);},g=()=>{y(null),k(false);},d=()=>{y(null),t();},f=()=>{if(!T)return null;let w=T,S=w.status==="pending"||w.status==="waiting"||w.status==="delayed",x=w.status==="succeeded",W=re(Se(w.destination_token_metadata,"png")||Gt("/icons/tokens/png/usdc.png")),D=w.provider_metadata?.details,O=D?.currencyIn,P=D?.currencyOut;O?.currency?.symbol||"USDC";P?.currency?.symbol||"USDC";let ae=Cm(w.source_amount_base_unit,w.source_token_metadata?.decimals),Me=Cm(w.destination_amount_base_unit,w.destination_token_metadata?.decimals),Oe=dy(w.source_amount_usd),X=bm(w.source_chain_type,w.source_chain_id),De=bm(w.destination_chain_type,w.destination_chain_id),he=()=>{w.explorer_url&&Linking.openURL(w.explorer_url);},xe=()=>{w.destination_explorer_url&&Linking.openURL(w.destination_explorer_url);};return jsxs(ht,{ref:h,style:fe.scrollContainer,contentContainerStyle:fe.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:fe.iconSection,children:[jsxs(View,{style:fe.iconWrapper,children:[jsx(Image,{source:{uri:W},style:fe.tokenIcon}),jsx(View,{style:[fe.statusBadge,{backgroundColor:S?a.warning:a.success,borderColor:a.background}],children:S?jsx(Bt,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx($e,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:fe.statusRow,children:[jsx(View,{style:[fe.statusDot,{backgroundColor:S?a.warning:a.success}]}),jsx(Text,{style:[fe.statusText,{color:s.container.titleColor,fontFamily:i.semibold}],children:S?"Processing":"Completed"})]}),jsx(Text,{style:[fe.dateText,{color:s.container.subtitleColor,fontFamily:i.regular}],children:uy(w.created_at||new Date().toISOString())})]}),jsxs(View,{style:[fe.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Sent"}),jsxs(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[ae," ",Sm(w.source_currency)]})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Received"}),jsxs(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[Me," ",Sm(w.destination_currency)]})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"USD Value"}),jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Oe})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Source Network"}),jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:X})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Destination Network"}),jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:De})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let Ue=!b;k(Ue),Ue?setTimeout(()=>{h.current?.scrollToEnd({animated:true});},100):h.current?.scrollTo({y:0,animated:true});},style:fe.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[fe.toggleText,{color:s.container.actionTitle,fontFamily:i.regular}],children:b?"See less":"See more details"}),b?jsx(To,{size:14,color:s.container.actionColor,strokeWidth:2}):jsx(Bt,{size:14,color:s.container.actionColor,strokeWidth:2})]}),b&&jsxs(View,{style:[fe.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[w.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:he,style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Deposit Tx"}),jsxs(View,{style:fe.cardRowRight,children:[jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:wm(w.transaction_hash)}),jsx(ko,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[fe.cardDivider,{backgroundColor:a.border}]})]}),w.destination_explorer_url&&x&&jsxs(TouchableOpacity,{onPress:xe,style:fe.cardRow,children:[jsx(Text,{style:[fe.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Completion Tx"}),jsxs(View,{style:fe.cardRowRight,children:[jsx(Text,{style:[fe.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:wm(w.destination_transaction_hashes[0])}),jsx(ko,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]})]})]})},_=c&&l.length===0;return jsxs(Fragment,{children:[jsx(Ir,{title:T?"Deposit Details":"Deposit Tracker",onClose:d,showClose:!T,showBack:!!T,onBack:g}),T?f():_?jsx(py,{}):jsx(ht,{style:fe.scrollContainer,contentContainerStyle:fe.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:fe.emptyContainer,children:[jsx(Text,{style:[fe.emptyText,{color:s.container.titleColor,fontFamily:i.medium}],children:"No deposits yet"}),jsx(Text,{style:[fe.emptySubtext,{color:s.container.subtitleColor,fontFamily:i.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:fe.executionsList,children:l.map(w=>jsx(Ol,{execution:w,onPress:()=>p(w)},w.id))})})]})}var fe=StyleSheet.create({scrollContainer:{flex:1,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:40},emptyContainer:{paddingVertical:40,paddingHorizontal:16,alignItems:"center"},emptyText:{fontSize:14,marginBottom:4},emptySubtext:{fontSize:12},executionsList:{paddingTop:8,gap:12},detailsContent:{paddingHorizontal:16,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},iconWrapper:{position:"relative",marginBottom:12},tokenIcon:{width:72,height:72,borderRadius:36},statusBadge:{position:"absolute",bottom:0,right:0,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardRowRight:{flexDirection:"row",alignItems:"center",gap:8},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"},toggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12,paddingHorizontal:4},toggleText:{fontSize:14},buttonSection:{marginTop:12,gap:10},actionButton:{flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:16,borderRadius:12},buttonIconLeft:{marginRight:12},buttonIconRight:{marginLeft:12},buttonText:{color:"#FFFFFF",fontSize:14,fontWeight:"600",flex:1,textAlign:"left"},hintText:{fontSize:12,textAlign:"center",marginTop:8}});function ma(e,t=true){let[r,o]=useState(null),[n,a]=useState(null),[i,s]=useState(false),[l,m]=useState(false),[c,C]=useState(null),[T,y]=useState(null);useEffect(()=>{!t||r||(s(true),Ls().then(p=>{o(p),C(null);}).catch(p=>{C(p instanceof Error?p:new Error(String(p)));}).finally(()=>{s(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(m(true),Vs(e).then(p=>{a(p),y(null);}).catch(p=>{y(p instanceof Error?p:new Error(String(p)));}).finally(()=>{m(false);}));},[t,e,n]);let b=i||l,k=c||T||null,h=null;if(r&&n){let p=n.blocked_country_codes||[],g=r.alpha2.toUpperCase();h=!p.some(d=>d.toUpperCase()===g);}return {isAllowed:h,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:b,error:k}}var Wd="unifold_recent_tokens",yy=5,Im=[{symbol:"ETH",chainType:"ethereum",chainId:"1"},{symbol:"SOL",chainType:"solana",chainId:"mainnet"},{symbol:"USDC",chainType:"solana",chainId:"mainnet"},{symbol:"POL",chainType:"ethereum",chainId:"137"},{symbol:"BNB",chainType:"ethereum",chainId:"56"},{symbol:"BTC",chainType:"bitcoin",chainId:"mainnet"}];async function Al(){try{let e=await Wc.getItem(Wd);return e?JSON.parse(e):[]}catch{return []}}async function by(e){try{let r=(await Al()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,yy);await Wc.setItem(Wd,JSON.stringify(o));}catch{}}async function Cy(e){try{let r=(await Al()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await Wc.setItem(Wd,JSON.stringify(r)),r}catch{return []}}function Ed({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:c}=F(),[C,T]=useState(""),[y,b]=useState([]);useEffect(()=>{e&&Al().then(b);},[e]),useEffect(()=>{e||T("");},[e]);let k=useMemo(()=>{let _=[];return r.forEach(R=>{R.chains.forEach(w=>{_.push({token:R,chain:w});});}),_},[r]),h=useMemo(()=>{let _=[],R=new Set,w=(S,x,W,D)=>{let O=`${S}-${x}:${W}`;if(R.has(O))return;let P=r.find(q=>q.symbol===S);if(!P)return;let j=P.chains.find(q=>q.chain_type===x&&q.chain_id===W);j&&(R.add(O),_.push({token:P,chain:j,isRecent:D}));};return y.forEach(S=>{w(S.symbol,S.chainType,S.chainId,true);}),Im.forEach(S=>{w(S.symbol,S.chainType,S.chainId,false);}),_},[r,y]),p=useMemo(()=>{if(!C.trim())return k;let _=C.toLowerCase();return k.filter(({token:R,chain:w})=>R.symbol.toLowerCase().includes(_)||R.name.toLowerCase().includes(_)||w.chain_name.toLowerCase().includes(_))},[k,C]),g=(_,R,w)=>Im.some(S=>S.symbol===_&&S.chainType===R&&S.chainId===w),d=async(_,R)=>{let w=`${R.chain_type}:${R.chain_id}`;if(!g(_.symbol,R.chain_type,R.chain_id)){await by({symbol:_.symbol,chainType:R.chain_type,chainId:R.chain_id});let S=await Al();b(S);}T(""),a(_.symbol,w),t();},f=async(_,R)=>{let w=await Cy({symbol:_.symbol,chainType:R.chain_type,chainId:R.chain_id});b(w);};return jsxs(ft,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,startExpanded:false,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:pt.header,children:[jsx(View,{style:pt.headerSpacer}),jsx(Text,{style:[pt.headerTitle,{color:c.header.titleColor,fontFamily:m.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:pt.closeButton,children:jsx(st,{size:20,color:c.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:pt.searchContainer,children:jsx(TextInput,{style:[pt.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:m.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],placeholder:"Search",placeholderTextColor:c.search.placeholderColor,value:C,onChangeText:T,autoCapitalize:"none",autoCorrect:false})}),h.length>0&&!C&&jsxs(View,{style:pt.quickSelectSection,children:[jsx(Text,{style:[pt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:m.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:pt.quickSelectScroll,children:h.map(({token:_,chain:R,isRecent:w})=>{let S=`${R.chain_type}:${R.chain_id}`;_.symbol===o&&S===n;return jsxs(View,{children:[w&&jsx(TouchableOpacity$1,{onPress:()=>f(_,R),style:pt.removeButton,children:jsx(st,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>d(_,R),activeOpacity:.7,style:[pt.quickSelectItem,{backgroundColor:c.card.backgroundColor,borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor}],children:[jsxs(View,{style:pt.tokenIconContainer,children:[jsx(Image,{source:{uri:re(Se(_,"png"))},style:pt.quickSelectIcon}),jsx(Image,{source:{uri:re(Se(R,"png"))},style:[pt.quickSelectChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:pt.quickSelectText,children:[jsx(Text,{style:[pt.quickSelectSymbol,{color:c.card.titleColor,fontFamily:m.medium}],children:_.symbol}),jsx(Text,{style:[pt.quickSelectChain,{color:c.card.subtitleColor,fontFamily:m.regular}],children:R.chain_name})]})]})]},`quick-${_.symbol}-${S}`)})})]}),jsx(Text,{style:[pt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:m.regular}],children:"All supported tokens"}),jsx(ht,{style:pt.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:pt.tokenListContent,children:p.length===0?jsx(View,{style:pt.emptyState,children:jsx(Text,{style:[pt.emptyText,{color:l.foregroundMuted,fontFamily:m.regular}],children:"No tokens found"})}):p.map(({token:_,chain:R})=>{let w=`${R.chain_type}:${R.chain_id}`,S=_.symbol===o&&w===n;return jsxs(TouchableOpacity$1,{onPress:()=>d(_,R),activeOpacity:.7,style:[pt.tokenItem,{backgroundColor:S?c.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:pt.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:re(Se(_,"png"))},style:pt.tokenIcon}),jsx(Image,{source:{uri:re(Se(R,"png"))},style:[pt.tokenChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:pt.tokenInfo,children:[jsx(Text,{style:[pt.tokenSymbol,{color:c.card.titleColor,fontFamily:m.medium}],children:_.symbol}),jsx(Text,{style:[pt.tokenChainName,{color:c.card.subtitleColor,fontFamily:m.regular}],children:R.chain_name})]}),jsxs(Text,{style:[pt.minDeposit,{color:c.card.labelColor,fontFamily:m.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:c.card.labelHighlightRightColor,fontFamily:m.regular},children:["$",R.minimum_deposit_amount_usd]})]})]},`${_.symbol}-${w}`)})})]})}var pt=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},closeButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",textAlign:"center",flex:1},headerSpacer:{width:28},searchContainer:{paddingHorizontal:16,paddingBottom:12},searchInput:{height:40,paddingHorizontal:16,fontSize:14},quickSelectSection:{marginBottom:12},sectionLabel:{fontSize:12,paddingHorizontal:16,marginBottom:8},quickSelectScroll:{paddingHorizontal:16,gap:8},quickSelectItem:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:8,paddingHorizontal:12},removeButton:{position:"absolute",top:-2,right:-6,zIndex:1,padding:2},tokenIconContainer:{position:"relative"},quickSelectIcon:{width:28,height:28,borderRadius:14},quickSelectChainBadge:{position:"absolute",bottom:-2,right:-2,width:14,height:14,borderRadius:7,borderWidth:2},quickSelectText:{alignItems:"flex-start"},quickSelectSymbol:{fontSize:12,fontWeight:"500"},quickSelectChain:{fontSize:10},tokenList:{flex:1},tokenListContent:{paddingHorizontal:16,paddingBottom:72,gap:4},emptyState:{padding:32,alignItems:"center"},emptyText:{fontSize:14},tokenItem:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:12},tokenIconContainerLarge:{position:"relative"},tokenIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenInfo:{flex:1},tokenSymbol:{fontSize:14,fontWeight:"500"},tokenChainName:{fontSize:12},minDeposit:{fontSize:12}});var El=(e,t)=>`${t}:${e}`,xy=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function Md({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:c="auto_ui",onExecutionsChange:C,onDepositSuccess:T,onDepositError:y,wallets:b,borderTopLeftRadius:k,borderTopRightRadius:h,sheetBorderRadius:p}){let{colors:g,fonts:d,components:f}=F(),_=s&&l?`${s}:${l}`:"solana:mainnet",[R,w]=useState("USDC"),[S,x]=useState(_),[W,D]=useState([]),[O,P]=useState(!b?.length),j=b?.length?b:W,[q,ae]=useState([]),[Me,Oe]=useState(true),[X,De]=useState(false),[he,xe]=useState(false),[Ue,we]=useState(false),[ne,Ie]=useState([]),[mt,Ve]=useState(new Map),[lt]=useState(()=>new Date),[He,Ne]=useState(null),[je,Be]=useState(false),[J,ce]=useState(null),[nt,it]=useState(false),ve=new Map;q.forEach(se=>{se.chains.forEach(ze=>{let E=`${ze.chain_type}:${ze.chain_id}`;ve.has(E)||ve.set(E,ze);});});let be=Array.from(ve.values()),ie=xy(S),de=be.find(se=>se.chain_type===ie.chainType&&se.chain_id===ie.chainId),Qt=de?.chain_type||"ethereum",ue=qo(j,Qt),le=ue?.address||"",Ce=useRef(false);useEffect(()=>{async function se(){try{Oe(!0),Ne(null);let E=await Gn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(ae(E.data),E.data.length>0&&!Ce.current){Ce.current=!0;let te,ye;if(s&&l)if(m)for(let me of E.data){let gt=me.chains.find(V=>V.chain_type===s&&V.chain_id===l&&V.token_address.toLowerCase()===m.toLowerCase());if(gt){te=me,ye=gt;break}}else for(let me of E.data){let gt=me.chains.find(V=>V.chain_type===s&&V.chain_id===l);if(gt){te=me,ye=gt;break}}if(!te&&a)for(let me of E.data){let gt=me.chains.find(V=>V.token_address.toLowerCase()===a.toLowerCase());if(gt){te=me,ye=gt;break}}te||(te=E.data.find(me=>me.symbol==="USDC"),te&&te.chains.length>0&&(ye=te.chains[0])),te||(te=E.data.find(me=>me.symbol==="USDT"),te&&te.chains.length>0&&(ye=te.chains[0])),te||(te=E.data[0],te.chains.length>0&&(ye=te.chains[0])),te&&w(te.symbol),ye&&x(El(ye.chain_id,ye.chain_type));}}catch(ze){console.error("Error fetching supported tokens:",ze),Ne("Failed to load supported tokens"),y?.({message:"Failed to load supported tokens",error:ze});}finally{Oe(false);}}se();},[t,a,n,o,s,l,m,y]),useEffect(()=>{C&&C(ne);},[ne,C]),useEffect(()=>{if(b?.length){P(false);return}if(W.length>0){P(false);return}let se=null,ze=false,E=async()=>{if(!ze){P(true);try{let te=await $o({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);ze||(D(te.data),Ne(null),P(!1));}catch(te){console.error("Error fetching wallets, retrying in 5s:",te),ze||(Ne(te instanceof Error?te.message:"Failed to load wallets"),P(false),se=setTimeout(E,5e3));}}};return E(),()=>{ze=true,se&&clearTimeout(se);}},[e,r,o,n,a,t,b,W.length]);let wt=ue?.id??"",{showWaitingUi:tt,handleIveDeposited:pe}=ca({depositConfirmationMode:c,depositAddress:le,chain:S,externalUserId:e,publishableKey:t,modalOpenedAt:lt,depositWalletId:wt,depositExecutions:ne,trackedExecutions:mt,setDepositExecutions:Ie,setTrackedExecutions:Ve,setLatestExecution:ce,setShowStatusSheet:Be,onDepositSuccess:T,onExecutionsChange:C,onDepositError:y});useEffect(()=>{if(!q.length)return;let se=q.find(E=>E.symbol===R);if(!se||se.chains.length===0)return;if(!se.chains.some(E=>El(E.chain_id,E.chain_type)===S)){let E=se.chains[0];x(El(E.chain_id,E.chain_type));}},[R,q,S]);let Qe=q.find(se=>se.symbol===R),xt=(Qe?.chains||[]).find(se=>El(se.chain_id,se.chain_type)===S),Pr=async()=>{if(le)try{Clipboard.setString(le),De(!0),setTimeout(()=>De(!1),2e3);}catch(se){console.error("Failed to copy:",se);}},Fr=xt?.estimated_price_impact_percent??0,U=xt?.max_slippage_percent??.25,Q=xt?.minimum_deposit_amount_usd??3;return Me?jsxs(View,{style:H.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:g.primary}),jsx(Text,{style:[H.loadingText,{color:g.foregroundMuted,fontFamily:d.regular}],children:"Loading currencies..."})]}):He&&q.length===0?jsxs(View,{style:H.errorContainer,children:[jsx(Text,{style:[H.errorText,{color:g.error,fontFamily:d.regular}],children:He}),jsx(Text,{style:[H.errorHint,{color:g.foregroundMuted,fontFamily:d.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:H.container,children:[jsxs(View,{style:H.selectorSection,children:[jsx(Text,{style:[H.selectorLabel,{color:f.card.labelColor,fontFamily:d.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>we(true),disabled:Me||q.length===0,style:[H.tokenSelectorButton,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],activeOpacity:.7,children:Me?jsxs(View,{style:H.tokenSelectorLoading,children:[jsx(View,{style:[H.loadingIcon,{backgroundColor:g.cardHover}]}),jsxs(View,{style:H.loadingTextContainer,children:[jsx(View,{style:[H.loadingLine,{backgroundColor:g.cardHover,width:60}]}),jsx(View,{style:[H.loadingLine,{backgroundColor:g.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:H.tokenIconWrapper,children:[Qe&&jsx(Image,{source:{uri:re(Se(Qe,"png"))},style:H.tokenMainIcon}),(xt||de)&&jsx(Image,{source:{uri:re(Se(xt||de,"png"))},style:[H.tokenChainBadge,{borderColor:f.card.backgroundColor,borderRadius:f.badge.borderRadius}]})]}),jsxs(View,{style:H.tokenSelectorInfo,children:[jsx(Text,{style:[H.tokenSelectorSymbol,{color:f.card.titleColor,fontFamily:d.semibold}],children:Qe?.symbol||R}),jsx(Text,{style:[H.tokenSelectorNetwork,{color:f.card.subtitleColor,fontFamily:d.regular}],numberOfLines:1,children:xt?.chain_name||de?.chain_name||"Select network"})]}),jsxs(View,{style:H.tokenSelectorRight,children:[jsxs(Text,{style:[H.minDepositText,{color:f.card.labelHighlightRightColor,fontFamily:d.medium}],children:["$",Q," min"]}),jsx(Tr,{size:16,color:f.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Ed,{visible:Ue,onClose:()=>we(false),tokens:q,selectedToken:R,selectedChainKey:S,onSelect:(se,ze)=>{w(se),x(ze);},borderTopLeftRadius:p?.tokenSelector?.borderTopLeftRadius??k,borderTopRightRadius:p?.tokenSelector?.borderTopRightRadius??h}),jsx(View,{style:H.qrContainer,children:jsx(View,{style:[H.qrWrapper,{backgroundColor:g.background,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth>0?f.card.borderWidth:1,borderColor:f.card.borderColor}],children:O?jsxs(View,{style:H.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:g.primary}),jsx(Text,{style:[H.loadingText,{color:g.foregroundMuted,fontFamily:d.regular}],children:"Loading..."})]}):le?jsx(us,{value:le,size:180,logoUri:re(Se(xt,"png")||Gt("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:H.qrLoading,children:jsx(Text,{style:[H.errorText,{color:g.error,fontFamily:d.regular}],children:"No address available"})})})}),jsxs(View,{style:H.addressSection,children:[jsxs(View,{style:H.addressHeader,children:[jsx(Text,{style:[H.addressLabel,{color:f.card.labelColor,fontFamily:d.medium}],children:"Deposit Address"}),X&&jsxs(View,{style:H.copiedIndicator,children:[jsx($e,{size:14,color:g.success,strokeWidth:2}),jsx(Text,{style:[H.copiedText,{color:g.success,fontFamily:d.regular}],children:"Copied"})]})]}),jsxs(nr,{cardTokens:f.transferCrypto.depositAddress.card,onPress:!O&&le?Pr:void 0,contentStyle:H.addressBox,children:[jsx(Text,{style:[H.addressText,{color:f.card.titleColor,fontFamily:d.regular}],numberOfLines:2,children:O?"Loading...":le||"No address available"}),jsx(View,{style:H.addressCopyIcon,children:jsx(No,{size:16,color:f.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[H.detailsCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>xe(!he),style:H.detailsHeader,children:[jsxs(View,{style:H.detailsRow,children:[jsx(View,{style:[H.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:H.chevronContainer,children:he?jsx(To,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(Bt,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),he&&jsxs(View,{style:H.detailsContent,children:[jsxs(View,{style:H.detailsRow,children:[jsx(View,{style:[H.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Price impact: ",Fr.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>it(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:H.detailsRow,children:[jsx(View,{style:[H.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Slippage: Auto \u2022 ",U.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>it(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Oi,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:H.detailsRow,children:[jsx(View,{style:[H.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(xa,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[H.detailsLabel,{color:f.card.titleColor,fontFamily:d.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(wl,{depositConfirmationMode:c,depositAddress:le,showWaitingUi:tt,latestExecution:J,onIveDeposited:pe}),jsx(TouchableOpacity$1,{style:H.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[H.termsText,{color:g.primary,fontFamily:d.regular}],children:"Terms apply"})}),jsxs(ft,{visible:nt,onClose:()=>it(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:p?.infoSheet?.borderTopLeftRadius??k,borderTopRightRadius:p?.infoSheet?.borderTopRightRadius??h,children:[jsxs(View,{style:[H.sheetHeader,{borderBottomColor:g.border}],children:[jsx(View,{style:H.sheetHeaderSpacer}),jsx(Text,{style:[H.sheetTitle,{color:f.header.titleColor,fontFamily:d.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>it(false),style:H.sheetCloseButton,children:jsx(st,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:H.infoSheetContent,children:[jsxs(View,{style:[H.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:H.infoCardHeader,children:[jsx(View,{style:[H.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(gn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Price Impact"}),jsxs(Text,{style:[H.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[Fr.toFixed(2),"%"]})]}),jsx(Text,{style:[H.infoCardDescription,{color:f.card.descriptionColor,fontFamily:d.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[H.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:H.infoCardHeader,children:[jsx(View,{style:[H.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(yn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[H.infoCardTitle,{color:f.card.titleColor,fontFamily:d.medium}],children:"Max Slippage"}),jsxs(Text,{style:[H.infoCardValue,{color:f.card.titleColor,fontFamily:d.medium}],children:[U.toFixed(2),"%"]})]}),jsx(Text,{style:[H.infoCardDescription,{color:f.card.descriptionColor,fontFamily:d.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),J&&jsx(ps,{visible:je,status:J.status,tokenIconUrl:J.destination_token_metadata?.icon_urls?.find(se=>se.format==="png")?.url||J.destination_token_metadata?.icon_url||Se(Qe,"png"),explorerUrl:J.explorer_url,completionExplorerUrl:J.destination_explorer_url,date:J.created_at?new Date(J.created_at):void 0,amountUsd:J.source_amount_usd?parseFloat(J.source_amount_usd):void 0,onClose:()=>Be(false),borderTopLeftRadius:p?.depositStatus?.borderTopLeftRadius??k,borderTopRightRadius:p?.depositStatus?.borderTopRightRadius??h})]})}var H=StyleSheet.create({container:{flex:1,paddingHorizontal:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:12,marginBottom:8},tokenSelectorButton:{flexDirection:"row",alignItems:"center",gap:12,padding:12},tokenSelectorLoading:{flexDirection:"row",alignItems:"center",gap:12,flex:1},loadingIcon:{width:40,height:40,borderRadius:20},loadingTextContainer:{flex:1},loadingLine:{height:12,borderRadius:6},tokenIconWrapper:{position:"relative"},tokenMainIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenSelectorInfo:{flex:1},tokenSelectorSymbol:{fontSize:14,fontWeight:"500"},tokenSelectorNetwork:{fontSize:12,marginTop:2},tokenSelectorRight:{flexDirection:"row",alignItems:"center",gap:8},minDepositText:{fontSize:12,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:8},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:12},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},termsContainer:{alignItems:"center",paddingVertical:8},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});var cn={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},stripeLinkPay:{title:"Pay with Stripe Link",subtitle:"Apple Pay or Card"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function Py(){let{colors:e,components:t}=F(),r=useRef(new Animated.Value(.5)).current,o=t.depositMenu.card.backgroundColor,n=e.cardHover;useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(r,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(r,{toValue:.5,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[r]);let a=({rightIcons:i=2})=>jsxs(View,{style:[$n.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[$n.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:$n.textBlock,children:[jsx(Animated.View,{style:[$n.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[$n.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:$n.rightIcons,children:Array.from({length:i}).map((s,l)=>jsx(Animated.View,{style:[$n.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:$n.container,children:[jsx(a,{rightIcons:3}),jsx(a,{rightIcons:2}),jsx(a,{rightIcons:0})]})}var $n=StyleSheet.create({container:{paddingTop:8,paddingBottom:24,gap:8},card:{marginHorizontal:16,flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:12,gap:12},leftIcon:{width:36,height:36},textBlock:{flex:1,gap:6},titleBar:{height:12,width:"70%",borderRadius:6},subtitleBar:{height:10,width:"50%",borderRadius:5},rightIcons:{flexDirection:"row",alignItems:"center",gap:4},rightIcon:{width:20,height:20,borderRadius:10}});function Fy({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,defaultChainType:c,defaultChainId:C,defaultTokenAddress:T,showBalance:y=false,hideDepositTracker:b=false,enableStripeLinkPay:k=false,StripeOnrampComponent:h,stripeOnrampEmail:p,stripeOnrampPhone:g,stripeMerchantIdentifier:d,stripePaymentSelectorPosition:f,stripeSkipSuccessConfirmation:_,stripeTheme:R,depositConfirmationMode:w="auto_ui",transferInputVariant:S="double_input",initialScreen:x="main",onDepositSuccess:W,onDepositError:D,sheetBorderRadius:O}){let P=O?.globalBorderTopLeftRadius,j=O?.globalBorderTopRightRadius,{colors:q,fonts:ae}=F(),[Me,Oe]=useState([]),[X,De]=useState(null),[he,xe]=useState("amount"),Ue=x==="tracker"&&!b?"tracker":x==="transfer"?"transfer":x==="card"?"card":"main",we=Ue==="main",[ne,Ie]=useState(Ue),{isAllowed:mt,isLoading:Ve}=ma(o,e);useEffect(()=>{if(!e||X)return;let ue=false;return Vs(o).then(async le=>{if(ue)return;let Ce=[];for(let wt of le?.transfer_crypto?.networks??[]){let tt=wt.icon_urls.find(pe=>pe.format==="png")?.url||wt.icon_urls.find(pe=>pe.format==="svg")?.url;tt&&Ce.push(re(tt));}for(let wt of le?.payment_networks?.networks??[]){let tt=wt.icon_urls.find(pe=>pe.format==="png")?.url||wt.icon_urls.find(pe=>pe.format==="svg")?.url;tt&&Ce.push(re(tt));}Ce.length>0&&await dd(Ce),ue||De(le);}).catch(console.error),()=>{ue=true;}},[e,X,o]);let lt=()=>{t();};useEffect(()=>{e&&(Ie(Ue),xe("amount"));},[e,Ue]);let He=useCallback(()=>{we?(Ie("main"),xe("amount")):lt();},[we,lt]),Ne=Me.filter(ue=>ue.status==="pending"||ue.status==="waiting").length,Be=!!(i&&s&&l&&m&&o)&&y!==false&&!!X,J=Ve||e&&!X,ce=mt===false,nt=null;if(ne==="stripe"&&h){let ue=jsx(h,{publishableKey:o,email:p,phone:g,externalUserId:r,recipientAddress:i??"",destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,merchantIdentifier:d,paymentSelectorPosition:f,skipSuccessConfirmation:_,onClose:He});nt=R?jsx(Di,{...R,children:ue}):ue;}let it=ne==="stripe"?.9:ne==="transfer"||ne==="card"?.94:ne==="tracker"?.6:ne==="main"?.5:void 0,ve=ne==="tracker"||ne==="main"?.9:void 0,ie={main:O?.main,transfer:O?.transferCrypto,card:O?.buyWithCard,stripe:O?.stripeLinkPay,tracker:O?.depositsTracker}[ne],de=ie?.borderTopLeftRadius??P,Qt=ie?.borderTopRightRadius??j;return jsxs(ft,{visible:e,onClose:ne==="main"?lt:He,closeOnBackdropPress:false,enablePanDownToClose:true,showHandle:true,heightPercent:it,maxHeightPercent:ve,borderTopLeftRadius:de,borderTopRightRadius:Qt,children:[ne==="main"&&jsxs(Fragment,{children:[jsx(Ir,{title:n,showBack:false,onClose:lt,showBalance:Be,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:X?.project_name}),J&&jsx(Py,{}),!J&&ce&&jsxs(View,{style:kr.centeredContainer,children:[jsx(View,{style:[kr.iconContainer,{backgroundColor:q.cardHover}],children:jsx(Is,{size:32,color:q.foreground,strokeWidth:1.5})}),jsx(Text,{style:[kr.blockedTitle,{color:q.foreground,fontFamily:ae.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[kr.blockedDescription,{color:q.foreground,opacity:.7,fontFamily:ae.regular}],children:"There are no supported tokens available from your current location."})]}),!J&&!ce&&jsxs(View,{style:kr.optionsContainer,children:[jsx(oa,{onPress:()=>Ie("transfer"),title:cn.transferCrypto.title,subtitle:cn.transferCrypto.subtitle,featuredTokens:X?.transfer_crypto?.networks}),jsx(ia,{onPress:()=>Ie("card"),title:cn.depositWithCard.title,subtitle:cn.depositWithCard.subtitle,paymentNetworks:X?.payment_networks?.networks}),k&&h&&jsx(la,{onPress:()=>Ie("stripe"),title:cn.stripeLinkPay.title,subtitle:cn.stripeLinkPay.subtitle}),!b&&jsx(sa,{onPress:()=>Ie("tracker"),title:cn.depositTracker.title,subtitle:cn.depositTracker.subtitle,badge:Ne>0?Ne:void 0})]})]}),ne==="transfer"&&jsxs(Fragment,{children:[jsx(Ir,{title:cn.transferCrypto.title,showBack:false,onClose:He,showBalance:Be,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:X?.project_name}),Ve&&jsx(View,{style:[kr.centeredContainer,kr.centeredFlex],children:jsx(ActivityIndicator,{color:q.primary})}),!Ve&&ce&&jsxs(View,{style:[kr.centeredContainer,kr.centeredFlex],children:[jsx(View,{style:[kr.iconContainer,{backgroundColor:q.cardHover}],children:jsx(Is,{size:32,color:q.foreground,strokeWidth:1.5})}),jsx(Text,{style:[kr.blockedTitle,{color:q.foreground,fontFamily:ae.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[kr.blockedDescription,{color:q.foreground,opacity:.7,fontFamily:ae.regular}],children:"There are no supported tokens available from your current location."})]}),!Ve&&!ce&&jsx(ht,{style:kr.transferScrollContainer,contentContainerStyle:kr.scrollContent,showsVerticalScrollIndicator:false,children:S==="single_input"?jsx(Md,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:C,defaultTokenAddress:T,depositConfirmationMode:w,onExecutionsChange:Oe,onDepositSuccess:W,onDepositError:D,borderTopLeftRadius:P,borderTopRightRadius:j,sheetBorderRadius:{tokenSelector:O?.tokenSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}}):jsx(kl,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:c,defaultChainId:C,defaultTokenAddress:T,depositConfirmationMode:w,onExecutionsChange:Oe,onDepositSuccess:W,onDepositError:D,borderTopLeftRadius:P,borderTopRightRadius:j,sheetBorderRadius:{tokenSelector:O?.tokenSelector,chainSelector:O?.chainSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}})})]}),ne==="card"&&jsxs(Fragment,{children:[jsx(Ir,{title:`Deposit ${a||"USDC"}`,showBack:he==="onramp",onBack:()=>xe("amount"),onClose:He,showBalance:Be,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:X?.project_name}),jsx(View,{style:kr.buyWithCardContainer,children:jsx(vl,{externalUserId:r,publishableKey:o,destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,onDepositSuccess:W,onDepositError:D,view:he,onViewChange:ue=>xe(ue),borderTopLeftRadius:P,borderTopRightRadius:j,sheetBorderRadius:{providerModal:O?.providerModal,webView:O?.webView,currencyModal:O?.currencyModal}})})]}),ne==="stripe"&&nt&&jsx(View,{style:kr.stripeLinkPayContainer,children:nt}),ne==="tracker"&&jsx(Ld,{active:ne==="tracker",onClose:He,executions:Me,externalUserId:r,publishableKey:o})]})}function Ul({theme:e="auto",...t}){return jsx(Fy,{...t})}var kr=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1},stripeLinkPayContainer:{flex:1},centeredContainer:{alignItems:"center",justifyContent:"center",paddingVertical:48,paddingHorizontal:16,minHeight:200},centeredFlex:{flex:1},iconContainer:{width:64,height:64,borderRadius:32,alignItems:"center",justifyContent:"center",marginBottom:16},blockedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},blockedDescription:{fontSize:14,textAlign:"center",maxWidth:280,lineHeight:20}});function Hl(e,t=true){return Xo({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>Va(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function Hd(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:a,enabled:i=true}=e;return Xo({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,a],queryFn:async()=>{let l=await Gn(a),m=null,c=null,C=null,T=null,y,b,k,h=l.data.some(p=>p.chains.some(g=>{let d=g.chain_type===t&&g.chain_id===r&&g.token_address.toLowerCase()===o.toLowerCase();return d&&(m=g.minimum_deposit_amount_usd,c=g.estimated_processing_time,C=g.max_slippage_percent,T=g.estimated_price_impact_percent,k=g.chain_name,b=p),d}));if(b){let p=Se(b,"png");p&&(y=re(p));}return {isSupported:h,minimumAmountUsd:m,estimatedProcessingTime:c,maxSlippagePercent:C,priceImpactPercent:T,errorMessage:h?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:y,chainName:k}},enabled:i&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function Nd(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:a,enabled:i=true}=e;return Xo({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,a],queryFn:async()=>{let l=await La(t,r,o,n,a);if(l.balance){let m=l.balance.token?.decimals??6,c=l.balance.token?.symbol??"",C=l.balance.amount,T=BigInt(C),y=BigInt(10**m),b=T/y,h=(T%y).toString().padStart(m,"0").replace(/0+$/,""),p=h?`${b}.${h}`:b.toString();return {balanceBaseUnit:C,balanceHuman:p,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:m,symbol:c}}return {balanceBaseUnit:"0",balanceHuman:"0",balanceUsd:"0",exchangeRate:null,decimals:6,symbol:""}},enabled:i&&(!!t&&!!r&&!!o&&!!n),staleTime:1e3*30,gcTime:1e3*60*5,refetchInterval:1e3*30,refetchOnMount:"always"})}var Dy=2500,Vy=3e3,Ly=6e4;function jd({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:a}){let[i,s]=useState([]),[l,m]=useState(false),c=useRef(new Date),C=useRef(new Map),T=useRef(false),y=useRef(n),b=useRef(a);return useEffect(()=>{y.current=n;},[n]),useEffect(()=>{b.current=a;},[a]),useEffect(()=>{o&&!T.current&&(c.current=new Date,C.current.clear()),o||C.current.clear(),T.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let k=c.current,h=async()=>{try{let g=await Qo(e,t,"withdraw"),d=new Date(k.getTime()-Ly),f=[...g.data].sort((S,x)=>{let W=S.created_at?new Date(S.created_at).getTime():0;return (x.created_at?new Date(x.created_at).getTime():0)-W}),_=["pending","waiting","delayed"],R=["succeeded","failed"],w=null;for(let S of f){let x=S.created_at?new Date(S.created_at):null;if(!x||x<d)continue;let W=C.current.get(S.id);if(!W){w=S;break}if(_.includes(W)&&R.includes(S.status)){w=S;break}}if(w){let S=w,x=S.created_at?new Date(S.created_at):null;if(!x||x<c.current)return;let W=C.current.get(S.id);C.current.set(S.id,S.status),s(D=>{let O=D.findIndex(P=>P.id===S.id);if(O>=0){let P=[...D];return P[O]=S,P}return [...D,S]}),S.status==="succeeded"&&(!W||_.includes(W))?y.current?.({message:"Withdrawal completed successfully",transaction:S}):S.status==="failed"&&W!=="failed"&&b.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:S});}}catch(g){console.error("Failed to fetch withdraw executions:",g),b.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:g});}};h();let p=setInterval(h,Dy);return m(true),()=>{clearInterval(p),m(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let k=async()=>{try{await Sc({deposit_wallet_id:r},t);}catch{}};k();let h=setInterval(k,Vy);return ()=>clearInterval(h)},[o,r,t]),{executions:i,isPolling:l}}var $d=(e,t)=>`${t}:${e}`;function ga({tokens:e,selectedTokenSymbol:t,selectedChainKey:r,onTokenChange:o,onChainChange:n,isLoading:a=false,tokenLabel:i="Receive token",chainLabel:s="Receive chain",tokenPickerBorderTopLeftRadius:l,tokenPickerBorderTopRightRadius:m,chainPickerBorderTopLeftRadius:c,chainPickerBorderTopRightRadius:C}){let{colors:T,fonts:y,components:b}=F(),[k,h]=useState(false),[p,g]=useState(false),d=b.card,f=t?e.find(S=>S.symbol===t):void 0,_=f?.chains||[],R=r?_.find(S=>$d(S.chain_id,S.chain_type)===r):void 0,w={backgroundColor:d.backgroundColor,borderRadius:d.borderRadius,borderWidth:d.borderWidth||1,borderColor:d.borderColor};return jsxs(View,{style:Xe.row,children:[jsxs(View,{style:Xe.col,children:[jsx(Text,{style:[Xe.label,{color:d.labelColor,fontFamily:y.medium}],children:i}),jsxs(TouchableOpacity,{style:[Xe.selectButton,w],onPress:()=>!a&&e.length>0&&h(true),activeOpacity:.7,disabled:a||e.length===0,children:[a?jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:y.regular}],children:"Loading..."}):f?jsxs(View,{style:Xe.selectedItem,children:[jsx(Image,{source:{uri:re(Se(f,"png"))},style:Xe.icon}),jsx(Text,{style:[Xe.selectedText,{color:d.titleColor,fontFamily:y.medium}],numberOfLines:1,children:f.symbol})]}):jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:y.regular}],children:"Select receive token"}),jsx(Bt,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:Xe.col,children:[jsx(Text,{style:[Xe.label,{color:d.labelColor,fontFamily:y.medium}],children:s}),jsxs(TouchableOpacity,{style:[Xe.selectButton,w,(!f||_.length===0)&&Xe.disabled],onPress:()=>!a&&f&&_.length>0&&g(true),activeOpacity:.7,disabled:a||!f||_.length===0,children:[R?jsxs(View,{style:Xe.selectedItem,children:[jsx(Image,{source:{uri:re(Se(R,"png"))},style:Xe.icon}),jsx(Text,{style:[Xe.selectedText,{color:d.titleColor,fontFamily:y.medium}],numberOfLines:1,children:R.chain_name})]}):jsx(Text,{style:[Xe.placeholder,{color:d.subtitleColor,fontFamily:y.regular}],children:"Chain"}),jsx(Bt,{size:16,color:d.actionColor,strokeWidth:2})]})]}),jsxs(ft,{visible:k,onClose:()=>h(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:l,borderTopRightRadius:m,children:[jsxs(View,{style:Xe.pickerHeader,children:[jsx(View,{style:Xe.pickerHeaderSpacer}),jsx(Text,{style:[Xe.pickerTitle,{color:T.foreground,fontFamily:y.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:Xe.pickerHeaderClose,onPress:()=>h(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(Vi,{data:e,keyExtractor:S=>S.symbol,contentContainerStyle:Xe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:S})=>jsxs(TouchableOpacity,{style:[Xe.pickerItem,{backgroundColor:S.symbol===t?T.cardHover:"transparent"}],onPress:()=>{o(S.symbol),h(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:re(Se(S,"png"))},style:Xe.pickerIcon}),jsx(Text,{style:[Xe.pickerItemText,{color:T.foreground,fontFamily:y.medium}],children:S.symbol}),jsx(Text,{style:[Xe.pickerItemSub,{color:T.foregroundMuted,fontFamily:y.regular}],children:S.name}),S.symbol===t&&jsx($e,{size:18,color:T.primary,strokeWidth:2.5})]})})]}),jsxs(ft,{visible:p,onClose:()=>g(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c,borderTopRightRadius:C,children:[jsxs(View,{style:Xe.pickerHeader,children:[jsx(View,{style:Xe.pickerHeaderSpacer}),jsx(Text,{style:[Xe.pickerTitle,{color:T.foreground,fontFamily:y.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:Xe.pickerHeaderClose,onPress:()=>g(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(Vi,{data:_,keyExtractor:S=>$d(S.chain_id,S.chain_type),contentContainerStyle:Xe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:S})=>{let x=$d(S.chain_id,S.chain_type);return jsxs(TouchableOpacity,{style:[Xe.pickerItem,{backgroundColor:x===r?T.cardHover:"transparent"}],onPress:()=>{n(x),g(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:re(Se(S,"png"))},style:Xe.pickerIcon}),jsx(Text,{style:[Xe.pickerItemText,{color:T.foreground,fontFamily:y.medium}],children:S.chain_name}),x===r&&jsx($e,{size:18,color:T.primary,strokeWidth:2.5})]})}})]})]})}var Xe=StyleSheet.create({row:{flexDirection:"column",gap:10},col:{},label:{fontSize:12,marginBottom:6},selectButton:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:12,gap:6,minHeight:48},selectedItem:{flex:1,flexDirection:"row",alignItems:"center",gap:6},icon:{width:20,height:20,borderRadius:10},selectedText:{fontSize:13,flexShrink:1},placeholder:{flex:1,fontSize:13},disabled:{opacity:.4},pickerHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:16,paddingBottom:12},pickerHeaderSpacer:{width:28},pickerHeaderClose:{width:28,alignItems:"flex-end"},pickerTitle:{flex:1,fontSize:16,textAlign:"center"},listContent:{paddingHorizontal:16,paddingVertical:8},pickerItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:12,borderRadius:10,gap:10},pickerIcon:{width:32,height:32,borderRadius:16},pickerItemText:{fontSize:15,flex:1},pickerItemSub:{fontSize:13}});function qd(e){let{chainType:t,chainId:r,tokenAddress:o,recipientAddress:n,publishableKey:a,enabled:i=true}=e,s=n?.trim()||"",l=!!t&&!!r&&!!o&&s.length>0;return Xo({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,s,a],queryFn:()=>wc({chain_type:t,chain_id:r,token_address:o,recipient_address:s},a),enabled:i&&l,staleTime:1e3*60*5,gcTime:1e3*60*30,retry:1,refetchOnMount:false})}function Ey(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function My(e,t){if(e<=0)return "0";if(t===0)return BigInt(Math.round(e)).toString();let r=e.toFixed(t),[o,n=""]=r.split("."),a=n.padEnd(t,"0").slice(0,t);return (BigInt(o)*BigInt(10**t)+BigInt(a)).toString()}function zy(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function jl({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:l,selectedChain:m,balanceData:c,isLoadingBalance:C,minimumWithdrawAmountUsd:T,estimatedProcessingTime:y,maxSlippagePercent:b,priceImpactPercent:k,canWithdraw:h,onDepositWalletCreation:p,onWithdraw:g,onWithdrawError:d,onWithdrawSubmitted:f,onViewTracker:_}){let R="https://unifold.io/terms",w="https://unifold.io/support",{colors:S,fonts:x,components:W}=F(),[D,O]=useState(s||""),[P,j]=useState(""),[q,ae]=useState(false),[Me,Oe]=useState(null),[X,De]=useState(false),[he,xe]=useState(""),Ue=useRef(null);useEffect(()=>{O(s||""),j(""),Oe(null);},[s]);let we=D.trim();useEffect(()=>{let pe=setTimeout(()=>xe(we),500);return ()=>clearTimeout(pe)},[we]);let{data:ne,isLoading:Ie,error:mt}=qd({chainType:m?.chain_type,chainId:m?.chain_id,tokenAddress:m?.token_address,recipientAddress:he,publishableKey:e,enabled:he.length>5&&!!m}),Ve=we!==he,lt=useMemo(()=>!we||we.length<=5||Ve||Ie?null:mt?"Invalid address":ne&&!ne.valid?ne.failure_code==="account_not_found"?`Account not found on ${m?.chain_name}`:ne.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${l?.symbol} on ${m?.chain_name}`:"Invalid address":null,[we,Ve,Ie,mt,ne,m,l]),He=!Ve&&!!ne?.valid&&!lt,Ne=useMemo(()=>c?.exchangeRate?parseFloat(c.exchangeRate):0,[c]),je=useMemo(()=>c?.balanceHuman?parseFloat(c.balanceHuman):0,[c]),Be=n||c?.symbol||"TOKEN",J=c?.decimals??6,ce=useMemo(()=>{let pe=parseFloat(P);return !pe||pe<=0?0:pe},[P]),nt=useMemo(()=>{let pe=parseFloat(P);return !pe||pe<=0?0:pe*Ne},[P,Ne]),it=useCallback(async()=>{try{let Qe=await tf("expo-clipboard").getStringAsync();Qe&&(O(Qe.trim()),Oe(null));}catch{}},[]),ve=useCallback(()=>{je<=0||j(c?.balanceHuman??"0");},[je,c]),be=T!==null&&nt>0&&nt<T,ie=ce>0&&je>0&&ce>je,de=we.length>0&&P.trim().length>0&&ce>0&&He&&!be&&!ie&&!!c,Qt=useCallback(async()=>{if(!(!l||!m||!de||!h)){ae(true),Oe(null);try{let pe=await p({destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,recipientAddress:we}),Qe=My(ce,J),ir=zy(ce,J),xt={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:Be,sourceTokenIconUrl:i,destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,destinationTokenSymbol:l.symbol,destinationChainName:m.chain_name,destinationTokenIconUrl:l?re(Se(l,"png")):void 0,amount:ir,amountBaseUnit:Qe,submittedAt:new Date,withdrawIntentAddress:pe.address,recipientAddress:we};await g(xt),f(xt);}catch(pe){let Qe=pe instanceof Error?pe.message:"Withdrawal failed. Please try again.",ir=Qe.length>120?"Withdrawal failed. Please try again.":Qe;Oe(ir),d?.({message:Qe,error:pe,code:"WITHDRAW_FAILED"});}finally{ae(false);}}},[l,m,de,h,we,t,r,o,Be,i,P,je,c,ce,J,nt,p,g,d,f]),ue=W.input,le=W.card,Ce=W.button,wt=lt?S.error:ue.borderColor,tt=useMemo(()=>q?"Processing...":ie?"Insufficient balance":be?`Minimum $${T?.toFixed(2)}`:Me?"Withdrawal failed \u2014 try again":"Withdraw",[q,ie,be,T,Me]);return jsxs(View,{style:Je.container,children:[jsxs(View,{children:[jsxs(View,{style:Je.labelRow,children:[jsx(Text,{style:[Je.label,{color:le.labelColor,fontFamily:x.medium}],children:"Recipient address"}),(Ve||Ie)&&we.length>5?jsx(ActivityIndicator,{size:"small",color:S.primary}):jsx(TouchableOpacity,{onPress:it,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(iu,{size:16,color:S.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[Je.inputRow,{backgroundColor:ue.backgroundColor,borderRadius:ue.borderRadius,borderWidth:ue.borderWidth,borderColor:wt}],children:jsx(TextInput,{style:[Je.textInput,{color:ue.textColor,fontFamily:x.regular}],placeholder:"Enter wallet address",placeholderTextColor:ue.placeholderColor,value:D,onChangeText:pe=>{O(pe),Oe(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>Ue.current?.focus()})}),lt?jsx(Text,{style:[Je.errorText,{color:S.error,fontFamily:x.regular}],children:lt}):null]}),jsxs(View,{children:[jsxs(Text,{style:[Je.label,{color:le.labelColor,fontFamily:x.medium,paddingBottom:8}],children:["Amount",T!=null&&T>0&&jsx(Text,{style:{color:S.warning,fontFamily:x.regular},children:` ($${T.toFixed(2)} min)`})]}),jsxs(View,{style:[Je.amountRow,{backgroundColor:ue.backgroundColor,borderRadius:ue.borderRadius,borderWidth:ue.borderWidth,borderColor:ue.borderColor}],children:[jsx(TextInput,{ref:Ue,style:[Je.amountInput,{color:ue.textColor,fontFamily:x.regular}],placeholder:"0.00",placeholderTextColor:ue.placeholderColor,value:P,onChangeText:pe=>{(pe===""||/^\d*\.?\d*$/.test(pe))&&(j(pe),Oe(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(Text,{style:[Je.unitLabel,{color:S.foregroundMuted,fontFamily:x.medium}],children:Be}),jsx(TouchableOpacity,{style:[Je.maxButton,{backgroundColor:`${S.primary}20`}],onPress:ve,activeOpacity:.7,children:jsx(Text,{style:[Je.maxText,{color:S.primary,fontFamily:x.medium}],children:"Max"})})]})]}),jsxs(View,{style:[Je.detailsCard,{marginTop:24,backgroundColor:le.backgroundColor,borderRadius:le.borderRadius,borderWidth:le.borderWidth||1,borderColor:le.borderColor}],children:[jsx(TouchableOpacity,{style:Je.detailsToggle,onPress:()=>De(!X),activeOpacity:.7,children:jsxs(View,{style:Je.detailsRow,children:[jsx(View,{style:[Je.detailIcon,{backgroundColor:le.iconBackgroundColor,borderRadius:le.iconContainerBorderRadius}],children:jsx(zr,{size:12,color:le.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Je.detailsLabel,{color:le.titleColor,fontFamily:x.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:x.medium},children:Ey(y)})]}),jsx(View,{style:{transform:[{rotate:X?"180deg":"0deg"}]},children:jsx(Bt,{size:16,color:le.actionColor,strokeWidth:2})})]})}),X&&jsxs(View,{style:Je.detailsExpanded,children:[jsxs(View,{style:Je.detailsRow,children:[jsx(View,{style:[Je.detailIcon,{backgroundColor:le.iconBackgroundColor,borderRadius:le.iconContainerBorderRadius}],children:jsx(yn,{size:12,color:le.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Je.detailsLabel,{color:le.titleColor,fontFamily:x.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:x.medium},children:["Auto \u2022 ",(b??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:Je.detailsRow,children:[jsx(View,{style:[Je.detailIcon,{backgroundColor:le.iconBackgroundColor,borderRadius:le.iconContainerBorderRadius}],children:jsx(gn,{size:12,color:le.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Je.detailsLabel,{color:le.titleColor,fontFamily:x.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:x.medium},children:[(k??0).toFixed(2),"%"]})]})]})]})]}),Me&&jsx(Text,{style:[Je.errorText,{color:S.error,fontFamily:x.regular,textAlign:"center"}],children:Me}),jsxs(View,{style:Je.withdrawRow,children:[jsxs(TouchableOpacity,{style:[Je.withdrawButton,{backgroundColor:Ce.primaryBackground,borderRadius:Ce.borderRadius,borderWidth:Ce.borderWidth,borderColor:Ce.borderColor,opacity:!de||!h||q?.5:1}],onPress:Qt,disabled:!de||!h||q,activeOpacity:.8,children:[q&&jsx(ActivityIndicator,{size:"small",color:Ce.primaryText}),jsx(Text,{style:[Je.withdrawButtonText,{color:Ce.primaryText,fontFamily:x.medium}],children:tt})]}),jsxs(View,{style:Je.footerRow,children:[jsxs(TouchableOpacity,{style:Je.historyLink,onPress:_,activeOpacity:.7,children:[jsx(zr,{size:14,color:S.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[Je.historyText,{color:S.foregroundMuted,fontFamily:x.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:Je.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(R),activeOpacity:.7,children:jsx(Text,{style:[Je.legalText,{color:S.foregroundMuted,fontFamily:x.regular}],children:"Terms"})}),jsx(Text,{style:[Je.legalSeparator,{color:S.foregroundMuted,fontFamily:x.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(w),activeOpacity:.7,children:jsx(Text,{style:[Je.legalText,{color:S.foregroundMuted,fontFamily:x.regular}],children:"Help"})})]})]})]})]})}var Je=StyleSheet.create({container:{gap:12,paddingHorizontal:16,paddingBottom:16},label:{fontSize:12},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:6},inputRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,minHeight:48},textInput:{flex:1,fontSize:14,paddingVertical:8},errorText:{fontSize:12,marginTop:4},amountRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,minHeight:48,gap:8},amountInput:{flex:1,fontSize:14,paddingVertical:8},unitLabel:{fontSize:14,flexShrink:0},maxButton:{paddingHorizontal:8,paddingVertical:4,borderRadius:6},maxText:{fontSize:12,fontWeight:"600"},withdrawRow:{gap:12},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},historyLink:{flexDirection:"row",alignItems:"center",gap:6},historyText:{fontSize:13},legalLinks:{flexDirection:"row",alignItems:"center",gap:6},legalText:{fontSize:13},legalSeparator:{fontSize:13},detailsCard:{paddingHorizontal:12,overflow:"hidden"},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13,flex:1},detailsExpanded:{gap:10,paddingBottom:12},withdrawButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:15,gap:8},withdrawButtonText:{fontSize:16,fontWeight:"600"}});function Ny(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function jy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Ql({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=F(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed",s=e.status==="failed"||e.status==="refunded",l=s?r.error:i?r.warning:r.success,m=re(Se(e.destination_token_metadata,"png")||Gt("/icons/tokens/png/usdc.png")),c=s?"Withdrawal Failed":i?"Withdrawal Processing":"Withdrawal Completed",C=Ny(e.created_at||new Date().toISOString()),T=jy(e.source_amount_usd);return jsxs(nr,{cardTokens:a,onPress:t,contentStyle:un.container,children:[jsxs(View,{style:un.iconContainer,children:[jsx(Image,{source:{uri:m},style:un.tokenIcon}),jsx(View,{style:[un.statusBadge,{backgroundColor:l,borderColor:a.backgroundColor}],children:s?jsx(Rs,{size:12,color:"#FFFFFF",strokeWidth:2.5}):i?jsx(_a,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx($e,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:un.textContainer,children:[jsx(Text,{style:[un.title,{color:a.titleColor,fontFamily:o.medium}],children:c}),jsx(Text,{style:[un.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:C})]}),jsxs(View,{style:un.rightContainer,children:[jsx(Text,{style:[un.amount,{color:a.textRightColor,fontFamily:o.medium}],children:T}),jsx(Tr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var un=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16}});function Gd(e){try{let t=new Date(e),o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],n=t.getDate(),a=t.getFullYear(),i=t.getHours(),s=t.getMinutes(),l=i>=12?"PM":"AM";i=i%12||12;let m=s<10?`0${s}`:`${s}`;return `${o} ${n}, ${a} at ${i}:${m} ${l}`}catch{return e}}function Hm(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function qy(e,t){if(e)try{return `$${Number(e).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}if(t)try{return `$${(Number(t)/1e6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}return "$0.00"}function Nm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function jm(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function ya({label:e,value:t,isLast:r}){let{fonts:o,components:n}=F(),a=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:Ee.detailRow,children:[jsx(Text,{style:[Ee.detailLabel,{color:a.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[Ee.detailValue,{color:a.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[Ee.divider,{backgroundColor:a.borderColor}]})]})}function Jd({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:a}){let{colors:i,fonts:s,components:l}=F(),[m,c]=useState([]),[C,T]=useState(!!n),y=l.card,b=l.button,k=l.header,h=l.container;useEffect(()=>{Cc().then(ae=>c(ae.data)).catch(()=>{});},[]),useEffect(()=>{T(!!n);},[e?.id]);let p=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,g=e?e.status==="failed"||e.status==="refunded":false,d=g?i.error:p?i.warning:i.success,f=g?"Failed":p?"Processing":"Completed",_=e?.destination_token_metadata?re(Se(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?re(t.destinationTokenIconUrl):re(Gt("/icons/tokens/png/usdc.png")),R=e?.created_at?Gd(e.created_at):t.submittedAt?Gd(t.submittedAt.toISOString()):Gd(new Date().toISOString()),w=e?`${Hm(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${Nm(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,S=e?`${Hm(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${Nm(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,x=e?qy(e.source_amount_usd,e.source_amount_base_unit):"$0.00",W=e?Da(m,e.source_chain_type,e.source_chain_id):t.sourceChainId,D=e?Da(m,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,O=e?.transaction_hash,P=e?.explorer_url,j=e?.destination_transaction_hashes?.[0],q=e?.destination_explorer_url;return jsxs(ht,{style:Ee.scroll,contentContainerStyle:Ee.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Ee.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Fi,{size:22,color:k.buttonColor,strokeWidth:2})}):jsx(View,{style:Ee.headerSpacer}),jsx(Text,{style:[Ee.headerTitle,{color:k.titleColor,fontFamily:s.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:Ee.headerSpacer}):jsx(TouchableOpacity,{onPress:a??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:k.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:Ee.iconContainer,children:[jsx(Image,{source:{uri:_},style:Ee.tokenIcon}),jsx(View,{style:[Ee.statusBadge,{backgroundColor:d}],children:g?jsx(Rs,{size:10,color:"#FFFFFF",strokeWidth:3}):p?jsx(View,{style:Ee.spinnerDot}):jsx($e,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Ee.statusRow,children:[jsx(View,{style:[Ee.statusDot,{backgroundColor:d}]}),jsx(Text,{style:[Ee.statusText,{color:d,fontFamily:s.medium}],children:f})]}),jsx(Text,{style:[Ee.dateText,{color:h.subtitleColor,fontFamily:s.regular}],children:R}),jsxs(View,{style:[Ee.detailsCard,{backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,borderWidth:y.borderWidth??1,borderColor:y.borderColor}],children:[jsx(ya,{label:"Amount Sent",value:w}),jsx(ya,{label:"Amount Received",value:S}),jsx(ya,{label:"USD Value",value:x}),jsx(ya,{label:"Source Network",value:W}),jsx(ya,{label:"Destination Network",value:D,isLast:true})]}),jsxs(TouchableOpacity,{style:Ee.moreDetailsRow,onPress:()=>T(ae=>!ae),activeOpacity:.7,children:[jsx(Text,{style:[Ee.moreDetailsText,{color:h.actionTitle,fontFamily:s.regular}],children:C?"See less":n?"See more":"See more details"}),C?jsx(To,{size:16,color:h.actionColor,strokeWidth:2}):jsx(Bt,{size:16,color:h.actionColor,strokeWidth:2})]}),C&&jsx(View,{style:[Ee.detailsCard,{backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,borderWidth:y.borderWidth??1,borderColor:y.borderColor}],children:O&&P?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:Ee.txRow,onPress:()=>Linking.openURL(P),activeOpacity:.7,children:[jsx(Text,{style:[Ee.txLabel,{color:y.subtitleColor,fontFamily:s.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[Ee.txHash,{color:y.titleColor,fontFamily:s.regular}],children:jm(O)}),jsx(ko,{size:14,color:y.actionColor,strokeWidth:2})]}),!p&&j&&q&&jsxs(Fragment,{children:[jsx(View,{style:[Ee.divider,{backgroundColor:y.borderColor}]}),jsxs(TouchableOpacity,{style:Ee.txRow,onPress:()=>Linking.openURL(q),activeOpacity:.7,children:[jsx(Text,{style:[Ee.txLabel,{color:y.subtitleColor,fontFamily:s.regular}],children:"Completion Tx"}),jsx(Text,{style:[Ee.txHash,{color:y.titleColor,fontFamily:s.regular}],children:jm(j)}),jsx(ko,{size:14,color:y.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:Ee.detailRow,children:jsx(Text,{style:[Ee.detailLabel,{color:y.subtitleColor,fontFamily:s.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:Ee.buttonRow,children:[jsx(TouchableOpacity,{style:[Ee.button,Ee.halfButton,{backgroundColor:b.secondaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Ee.buttonText,{color:b.secondaryText,fontFamily:s.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[Ee.button,Ee.halfButton,{backgroundColor:b.primaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Ee.buttonText,{color:b.primaryText,fontFamily:s.medium}],children:"Close"})})]})]})}var Ee=StyleSheet.create({scroll:{flex:1},container:{alignItems:"center",paddingHorizontal:20,paddingTop:8,paddingBottom:32,gap:12},headerRow:{flexDirection:"row",alignItems:"center",width:"100%",paddingTop:16,marginBottom:4},headerSpacer:{width:28},headerTitle:{flex:1,fontSize:16,textAlign:"center"},iconContainer:{position:"relative",marginTop:8},tokenIcon:{width:64,height:64,borderRadius:32},statusBadge:{position:"absolute",bottom:-2,right:-2,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center"},spinnerDot:{width:10,height:10,borderRadius:5,borderWidth:2,borderColor:"#FFFFFF",borderTopColor:"transparent"},statusRow:{flexDirection:"row",alignItems:"center",gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:15},dateText:{fontSize:13,marginTop:-4},detailsCard:{width:"100%",paddingHorizontal:16,overflow:"hidden"},detailRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailLabel:{fontSize:13,flex:1},detailValue:{fontSize:13,flexShrink:0,maxWidth:"55%",textAlign:"right"},divider:{height:StyleSheet.hairlineWidth,opacity:.5},moreDetailsRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingHorizontal:4},moreDetailsText:{fontSize:14},txRow:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:12},txLabel:{fontSize:13},txHash:{fontSize:13,flex:1,textAlign:"right"},buttonRow:{flexDirection:"row",gap:10,width:"100%",marginTop:4},button:{paddingVertical:14,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:14}});function $m(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Kl({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:a,components:i}=F(),s=t.length>0?t[t.length-1]:null,l=s?.status==="succeeded",m=s?.status==="failed",c={borderRadius:i.button.borderRadius,borderWidth:i.button.borderWidth,borderColor:i.button.borderColor};return l?jsxs(View,{style:Rt.container,children:[jsx(TouchableOpacity,{style:Rt.closeButton,onPress:r,children:jsx(st,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Rt.iconRing,{backgroundColor:n.successBackground}],children:jsx($e,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[Rt.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[Rt.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",$m(e.recipientAddress)]}),jsxs(View,{style:Rt.buttonRow,children:[jsx(TouchableOpacity,{style:[Rt.button,Rt.halfButton,c,{backgroundColor:i.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Rt.buttonText,{color:i.button.secondaryText,fontFamily:a.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[Rt.button,Rt.halfButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Rt.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]})]}):m?jsxs(View,{style:Rt.container,children:[jsx(TouchableOpacity,{style:Rt.closeButton,onPress:r,children:jsx(st,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Rt.iconRing,{backgroundColor:n.errorBackground}],children:jsx(st,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[Rt.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[Rt.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[Rt.button,Rt.fullButton,c,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Rt.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]}):jsxs(View,{style:Rt.container,children:[jsx(TouchableOpacity,{style:Rt.closeButton,onPress:r,children:jsx(st,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(kt,{size:80,strokeWidth:4,iconSize:68,gradientFrom:n.primary,gradientTo:n.primary,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:re(e.sourceTokenIconUrl)},style:Rt.tokenIconFill}):jsx(View,{style:[Rt.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[Rt.title,{color:n.foreground,fontFamily:a.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[Rt.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",$m(e.recipientAddress)]})]})}var Rt=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:48,paddingBottom:24},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconRing:{width:80,height:80,borderRadius:40,alignItems:"center",justifyContent:"center",marginBottom:20},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},title:{fontSize:20,marginBottom:8,textAlign:"center"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,marginBottom:24},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,alignItems:"center",justifyContent:"center",borderRadius:12},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:15}});function Zy(e){let t=e.source_token_metadata?.decimals??6,r=e.source_amount_base_unit??"0",o=Number(r)/Math.pow(10,t),n=o>=1?o.toFixed(2):o.toPrecision(4).replace(/\.?0+$/,"");return {sourceChainType:e.source_chain_type,sourceChainId:e.source_chain_id,sourceTokenAddress:e.source_token_address,sourceTokenSymbol:e.source_currency?.toUpperCase()??"",sourceTokenIconUrl:re(Se(e.source_token_metadata,"png")),destinationChainType:e.destination_chain_type,destinationChainId:e.destination_chain_id,destinationTokenAddress:e.destination_token_address,destinationTokenSymbol:e.destination_currency?.toUpperCase()??"",destinationTokenIconUrl:re(Se(e.destination_token_metadata,"png")),amount:n,amountBaseUnit:r,submittedAt:e.created_at?new Date(e.created_at):void 0,withdrawIntentAddress:e.deposit_wallet?.address??"",recipientAddress:e.recipient_address??""}}var qm=(e,t)=>`${t}:${e}`;function Xy(){let{colors:e}=F(),t=useRef(new Animated.Value(.5)).current,r=e.cardHover;return useEffect(()=>{let o=Animated.loop(Animated.sequence([Animated.timing(t,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(t,{toValue:.5,duration:800,useNativeDriver:true})]));return o.start(),()=>o.stop()},[t]),jsx(View,{style:{gap:12,paddingHorizontal:16},children:[1,2,3].map(o=>jsx(Animated.View,{style:{height:48,borderRadius:12,backgroundColor:r,opacity:t}},o))})}function Jl({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:a,defaultDestinationChainType:i,defaultDestinationChainId:s,defaultDestinationTokenAddress:l,modalTitle:m="Withdraw Crypto",onWithdraw:c,onWithdrawSuccess:C,onWithdrawError:T,heightPercent:y=.94,sheetBorderRadius:b,sourceChainType:k,sourceChainId:h,sourceTokenAddress:p,sourceTokenSymbol:g,sourceChainName:d,sourceTokenIconUrl:f}){let{colors:_,fonts:R}=F(),[w,S]=useState("form"),[x,W]=useState(k),[D,O]=useState(h),[P,j]=useState(p),[q,ae]=useState(g),[Me,Oe]=useState(d),[X,De]=useState(f),[he,xe]=useState(null),[Ue,we]=useState(null),[ne,Ie]=useState(null),[mt,Ve]=useState(),[lt,He]=useState([]),[Ne,je]=useState(null),[Be,J]=useState("form"),ce=useRef(new Animated.Value(Dimensions.get("window").width)).current,nt=useRef(null),it=!!x&&!!D&&!!P,{data:ve,isLoading:be}=Hl(r,e&&w==="form"),ie=ve?.data??[],{data:de,isLoading:Qt}=Hd({sourceChainType:x,sourceChainId:D,sourceTokenAddress:P,sourceTokenSymbol:q,publishableKey:r,enabled:e&&it&&w==="form"}),{data:ue,isLoading:le}=Nd({address:n,chainType:x,chainId:D,tokenAddress:P,publishableKey:r,enabled:e&&it}),{executions:Ce}=jd({userId:o,publishableKey:r,depositWalletId:mt,enabled:!!mt&&e,onWithdrawSuccess:C,onWithdrawError:T});useEffect(()=>{if(!e||w!=="tracker")return;let z=false;return Qo(o,r,"withdraw").then(Ft=>{z||He(Ft.data);}).catch(console.error),()=>{z=true;}},[e,w,o,r]),useEffect(()=>{e&&(nt.current&&(clearTimeout(nt.current),nt.current=null),S("form"),W(k),O(h),j(p),ae(g),Oe(d),De(f),xe(null),we(null),Ie(null),Ve(void 0),He([]),je(null),J("form"),ce.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{nt.current&&clearTimeout(nt.current);},[]),useEffect(()=>{X||de?.iconUrl&&De(de.iconUrl);},[de?.iconUrl,X]),useEffect(()=>{Me||de?.chainName&&Oe(de.chainName);},[de?.chainName,Me]),useEffect(()=>{if(!ie.length||he)return;let z,Ft;if(i&&s)if(l)for(let St of ie){let Mr=St.chains.find(Xt=>Xt.chain_type===i&&Xt.chain_id===s&&Xt.token_address.toLowerCase()===l.toLowerCase());if(Mr){z=St,Ft=Mr;break}}else for(let St of ie){let Mr=St.chains.find(Xt=>Xt.chain_type===i&&Xt.chain_id===s);if(Mr){z=St,Ft=Mr;break}}z||(z=ie[0]),z&&(xe(z),we(Ft??z.chains[0]??null));},[ie,he,i,s,l]),useEffect(()=>{w==="confirming"&&Ce.length>0&&S("details");},[w,Ce]);let wt=useCallback(()=>{t(),nt.current=setTimeout(()=>{S("form"),W(k),O(h),j(p),ae(g),Oe(d),De(f),xe(null),we(null),Ie(null),Ve(void 0),He([]),je(null),J("form"),nt.current=null;},300);},[t,k,h,p,g,d,f]),tt=useCallback(z=>{let Ft=ie.find(St=>St.symbol===z);Ft&&(xe(Ft),Ft.chains.length>0&&we(Ft.chains[0]));},[ie]),pe=useCallback(z=>{if(!he)return;let Ft=he.chains.find(St=>qm(St.chain_id,St.chain_type)===z);Ft&&we(Ft);},[he]),Qe=useCallback(async z=>{let Ft=await $o({external_user_id:o,destination_chain_type:z.destinationChainType,destination_chain_id:z.destinationChainId,destination_token_address:z.destinationTokenAddress,recipient_address:z.recipientAddress,action_type:"withdraw"},r),St=qo(Ft.data,x??"");if(!St)throw new Error(`No deposit wallet found for chain type: ${x}`);return Ve(St.id),{id:St.id,address:St.address}},[o,r,x]),ir=useCallback(z=>{Ie(z),S("confirming");},[]),xt=useCallback(z=>{je(z),ce.setValue(Dimensions.get("window").width),Animated.timing(ce,{toValue:0,duration:280,useNativeDriver:true}).start();},[ce]),Pr=useCallback(()=>{Animated.timing(ce,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>je(null));},[ce]),Fr=be||Qt,U=de?.isSupported??null,Q=w==="confirming"?"Withdrawal Status":m,se=b?.globalBorderTopLeftRadius,ze=b?.globalBorderTopRightRadius,E=b?.main?.borderTopLeftRadius??se,te=b?.main?.borderTopRightRadius??ze,ye=b?.tokenSelector?.borderTopLeftRadius??se,me=b?.tokenSelector?.borderTopRightRadius??ze,gt=b?.chainSelector?.borderTopLeftRadius??se,V=b?.chainSelector?.borderTopRightRadius??ze,Or=(()=>{if(w!=="form"||!it||le||!ue)return;let z=q||ue.symbol,Ft=ue.balanceUsd;if(Ft!=null){let Xt=`$${parseFloat(Ft).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return z?`Balance: ${Xt} ${z}`:`Balance: ${Xt}`}let St=ue.balanceHuman;if(!(!St||St==="0"))return z?`Balance: ${St} ${z}`:`Balance: ${St}`})();return jsx(ft,{visible:e,onClose:wt,closeOnBackdropPress:false,enablePanDownToClose:w==="tracker"||w==="form",showHandle:w==="tracker"||w==="form",heightPercent:w==="confirming"?.3:w==="details"?.7:w==="tracker"?.6:y,maxHeightPercent:w==="tracker"?.9:void 0,borderTopLeftRadius:E,borderTopRightRadius:te,children:w==="confirming"&&ne?jsx(Kl,{txInfo:ne,executions:Ce,onClose:wt,onViewTracker:()=>{J("confirming"),S("tracker");}}):w==="details"&&ne?jsx(Jd,{execution:Ce.length>0?Ce[Ce.length-1]:null,txInfo:ne,onClose:wt,onViewHistory:()=>{J("details"),S("tracker");},onHeaderClose:()=>S("form")}):w==="tracker"?jsxs(View,{style:zo.trackerContainer,children:[jsx(Ir,{title:"Withdrawal History",onClose:()=>S(Be)}),lt.length===0?jsx(View,{style:zo.emptyState,children:jsx(Text,{style:[zo.emptyText,{color:_.foregroundMuted,fontFamily:R.regular}],children:"No withdrawals to track yet"})}):jsx(Vi,{data:lt,keyExtractor:z=>z.id,contentContainerStyle:zo.listContent,showsVerticalScrollIndicator:false,renderItem:({item:z})=>jsx(Ql,{execution:z,onPress:()=>xt(z)})}),Ne&&jsx(Animated.View,{style:[zo.historyDetailOverlay,{backgroundColor:_.background,transform:[{translateX:ce}]}],children:jsx(Jd,{execution:Ne,txInfo:Zy(Ne),onClose:wt,onBack:Pr,onViewHistory:Pr})})]}):jsxs(Fragment,{children:[jsx(Ir,{title:Q,subtitle:Or,onClose:wt}),Fr?jsx(Xy,{}):U===false?jsxs(View,{style:zo.unsupportedContainer,children:[jsx(Text,{style:[zo.unsupportedTitle,{color:_.foreground,fontFamily:R.medium}],children:"Unsupported Token"}),jsx(Text,{style:[zo.unsupportedMessage,{color:_.foregroundMuted,fontFamily:R.regular}],children:de?.errorMessage})]}):jsx(eb,{publishableKey:r,sourceChainType:x??"",sourceChainId:D??"",sourceTokenAddress:P??"",sourceTokenSymbol:q,sourceChainName:Me,sourceTokenIconUrl:X,recipientAddressProp:a,destinationTokens:ie,selectedToken:he,selectedChain:Ue,selectedChainKey:Ue?qm(Ue.chain_id,Ue.chain_type):null,onTokenChange:tt,onChainChange:pe,tokensLoading:be,balanceData:ue??null,isLoadingBalance:le,sourceValidation:de??null,onDepositWalletCreation:Qe,onWithdraw:c,onWithdrawError:T,onWithdrawSubmitted:ir,onViewTracker:()=>{J("form"),S("tracker");},tokenSelectorLeft:ye,tokenSelectorRight:me,chainSelectorLeft:gt,chainSelectorRight:V})]})})}function eb({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,destinationTokens:l,selectedToken:m,selectedChain:c,selectedChainKey:C,onTokenChange:T,onChainChange:y,tokensLoading:b,balanceData:k,isLoadingBalance:h,sourceValidation:p,onDepositWalletCreation:g,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:_,onViewTracker:R,tokenSelectorLeft:w,tokenSelectorRight:S,chainSelectorLeft:x,chainSelectorRight:W}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(ht,{style:{flex:1,paddingTop:16},contentContainerStyle:zo.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:zo.doubleInputWrapper,children:jsx(ga,{tokens:l,selectedTokenSymbol:m?.symbol??null,selectedChainKey:C,onTokenChange:T,onChainChange:y,isLoading:b,tokenPickerBorderTopLeftRadius:w,tokenPickerBorderTopRightRadius:S,chainPickerBorderTopLeftRadius:x,chainPickerBorderTopRightRadius:W})}),jsx(jl,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:m,selectedChain:c,balanceData:k,isLoadingBalance:h,minimumWithdrawAmountUsd:p?.minimumAmountUsd??null,estimatedProcessingTime:p?.estimatedProcessingTime??null,maxSlippagePercent:p?.maxSlippagePercent??null,priceImpactPercent:p?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:g,onWithdraw:d,onWithdrawError:f,onWithdrawSubmitted:_,onViewTracker:R})]})})}var zo=StyleSheet.create({scrollContent:{paddingBottom:32},doubleInputWrapper:{paddingHorizontal:16,paddingBottom:12,paddingTop:4},listContent:{paddingHorizontal:16,paddingBottom:32,gap:8},trackerContainer:{flex:1,overflow:"hidden"},historyDetailOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0},emptyState:{flex:1,alignItems:"center",justifyContent:"center",paddingVertical:48},emptyText:{fontSize:14},unsupportedContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24,paddingVertical:48},unsupportedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},unsupportedMessage:{fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280}});StyleSheet.create({container:{paddingHorizontal:16,paddingTop:16,paddingBottom:24,gap:16},fieldGroup:{gap:8},fieldLabel:{fontSize:12},walletCard:{paddingHorizontal:12,paddingVertical:12,minHeight:48,justifyContent:"center"},walletAddress:{fontSize:13},primaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginTop:4},primaryButtonText:{fontSize:16},secondaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center"},secondaryButtonText:{fontSize:16}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var Gm=createContext(null);function db({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new od({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,a]=useState(false),[i,s]=useState(null),[l,m]=useState(false),[c,C]=useState(null),T=useColorScheme(),y=useRef(false);y.current||(va({publishableKey:t}),y.current=true);let b=useMemo(()=>{let P=r?.appearance||"dark";return P==="auto"?T==="dark"?"dark":"light":P},[r?.appearance,T]);useEffect(()=>{if(!t||t.trim()===""){console.error("Unifold: publishableKey is required. Please provide a valid publishable key.");return}!t.startsWith("pk_test_")&&!t.startsWith("pk_live_")&&console.warn('Unifold: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),va({publishableKey:t});},[t]),useEffect(()=>()=>{h.current&&clearTimeout(h.current),R.current&&clearTimeout(R.current);},[]);let k=useRef(null),h=useRef(null),p=useCallback(P=>{h.current&&(clearTimeout(h.current),h.current=null),k.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),k.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),k.current=null);let j=new Promise((q,ae)=>{k.current={resolve:q,reject:ae};});return s(P),a(true),j},[]),g=useCallback(()=>{k.current&&(k.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),k.current=null),a(false),h.current=setTimeout(()=>{s(null),h.current=null;},200);},[]),d=useCallback(P=>{i?.onSuccess&&i.onSuccess(P),k.current&&(k.current.resolve(P),k.current=null);},[i]),f=useCallback(P=>{console.error("[UnifoldProvider] Deposit error:",P),i?.onError&&i.onError(P),k.current&&(k.current.reject(P),k.current=null);},[i]),_=useRef(null),R=useRef(null),w=useRef(void 0),S=useCallback(P=>{R.current&&(clearTimeout(R.current),R.current=null),_.current&&(console.warn("[UnifoldProvider] A withdrawal is already in progress. Cancelling previous withdrawal."),_.current.reject({message:"Withdrawal cancelled - new withdrawal started",code:"WITHDRAW_SUPERSEDED"}),_.current=null);let j=new Promise((q,ae)=>{_.current={resolve:q,reject:ae};});return w.current=P.onClose,C(P),m(true),j},[]),x=useCallback(()=>{_.current&&(_.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),_.current=null),w.current?.(),w.current=void 0,m(false),R.current=setTimeout(()=>{C(null),R.current=null;},200);},[]),W=useCallback(P=>{c?.onSuccess&&c.onSuccess(P),_.current&&(_.current.resolve(P),_.current=null);},[c]),D=useCallback(P=>{console.error("[UnifoldProvider] Withdraw error:",P),c?.onError&&c.onError(P),_.current&&(_.current.reject(P),_.current=null);},[c]),O=useMemo(()=>({publishableKey:t,beginDeposit:p,closeDeposit:g,beginWithdraw:S,closeWithdraw:x}),[t,p,g,S,x]);return jsx(sd,{client:o,children:jsx(Gm.Provider,{value:O,children:jsxs(Di,{mode:b,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,i&&jsx(Ul,{visible:n,onClose:g,publishableKey:t,modalTitle:r?.modalTitle,externalUserId:i.externalUserId,destinationChainType:i.destinationChainType,destinationChainId:i.destinationChainId,destinationTokenSymbol:i.destinationTokenSymbol,recipientAddress:i.recipientAddress,destinationTokenAddress:i.destinationTokenAddress,defaultChainType:i.defaultChainType,defaultChainId:i.defaultChainId,defaultTokenAddress:i.defaultTokenAddress,showBalance:i.showBalance,stripeOnrampEmail:i.stripeOnrampEmail,stripeOnrampPhone:i.stripeOnrampPhone,stripeTheme:{mode:b,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components},depositConfirmationMode:i.depositConfirmationMode??"auto_ui",initialScreen:i.initialScreen,hideDepositTracker:r?.hideDepositTracker,transferInputVariant:r?.transferInputVariant,enableStripeLinkPay:r?.enableStripeLinkPay,stripeMerchantIdentifier:r?.stripeMerchantIdentifier,stripePaymentSelectorPosition:r?.stripePaymentSelectorPosition,stripeSkipSuccessConfirmation:r?.stripeSkipSuccessConfirmation,StripeOnrampComponent:r?.enableStripeLinkPay?sp():void 0,onDepositSuccess:d,onDepositError:f,theme:b,sheetBorderRadius:r?.sheetBorderRadius}),c&&jsx(Jl,{visible:l,onClose:x,publishableKey:t,externalUserId:c.externalUserId,senderAddress:c.senderAddress,recipientAddress:c.recipientAddress,sourceChainType:c.sourceChainType,sourceChainId:c.sourceChainId,sourceTokenAddress:c.sourceTokenAddress,sourceTokenSymbol:c.sourceTokenSymbol,defaultDestinationChainType:c.defaultDestinationChainType,defaultDestinationChainId:c.defaultDestinationChainId,defaultDestinationTokenAddress:c.defaultDestinationTokenAddress,onWithdraw:c.withdraw,onWithdrawSuccess:W,onWithdrawError:D,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function ub(){let e=useContext(Gm);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
- export{Qa as AmountScreen,ft as BottomSheet,Ka as KYCWizardScreen,el as OnrampScreen,tl as StripeOnramp,np as StripeOnrampPreconfigure,db as UnifoldProvider,Se as getPreferredIcon,Na as getStripePublishableKey,Va as getSupportedDestinationTokens,re as normalizeIconUrl,rl as registerStripeOnramp,cu as setDevApiUrl,Ha as setStripeOnrampApiUrl,Ua as setStripeOnrampPublishableKey,ma as useAllowedCountry,Ga as useStripeOnramp,F as useTheme,ub as useUnifold};
1
+ import*as ni from'react';import ni__default,{createContext,useContext,useState,useRef,useCallback,useEffect,useMemo,useId,Fragment as Fragment$1}from'react';import {StyleSheet,ScrollView,useWindowDimensions,Platform,PanResponder,Modal,View,Pressable,TouchableOpacity,Text,ActivityIndicator,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Animated,Image,Easing,Linking,Dimensions,Clipboard,FlatList}from'react-native';import Pt,{G,Path,Defs,ClipPath,Rect,LinearGradient,Stop,Circle,Polyline,Line,SvgXml,SvgUri}from'react-native-svg';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {GestureHandlerRootView,TouchableOpacity as TouchableOpacity$1}from'react-native-gesture-handler';import ap,{useSharedValue,withSpring,withTiming,runOnJS,useAnimatedStyle,interpolate,Extrapolation}from'react-native-reanimated';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import Fd from'@react-native-async-storage/async-storage';import Py from'expo-constants';import db from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var Zu=e=>{throw TypeError(e)};var hh=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Nc=(e,t,r)=>t.has(e)||Zu("Cannot "+r);var f=(e,t,r)=>(Nc(e,t,"read from private field"),r?r.call(e):t.get(e)),te=(e,t,r)=>t.has(e)?Zu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),A=(e,t,r,o)=>(Nc(e,t,"write to private field"),t.set(e,r),r),Ue=(e,t,r)=>(Nc(e,t,"access private method"),r);var Js=(e,t,r,o)=>({set _(n){A(e,t,n);},get _(){return f(e,t,o)}});var jc={light:{background:"#FFFFFF",card:"#F8FAFC",cardHover:"#F1F5F9",foreground:"#0F172A",foregroundMuted:"#64748B",foregroundSubtle:"#94A3B8",border:"#E2E8F0",borderSecondary:"#CBD5E1",primary:"#3B82F6",primaryForeground:"#FFFFFF",success:"#22C55E",successBackground:"#DCFCE7",warning:"#F59E0B",warningBackground:"#FEF3C7",error:"#EF4444",errorBackground:"#FEE2E2",overlay:"rgba(0, 0, 0, 0.5)"},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)"}},$c=jc;function ol(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function Zs(e,t,r){let o=r?t?.[r]:void 0,n=(c,y,T)=>{let w=o?.[c]?.[y];if(w!==void 0)return w;let m=t?.[c]?.[y];return m!==void 0?m:T},i={backgroundColor:n("card","backgroundColor",e.card),titleColor:n("card","titleColor",e.foreground),subtitleColor:n("card","subtitleColor",e.foregroundMuted),labelColor:n("card","labelColor",e.foregroundMuted),headerColor:n("card","headerColor",e.foregroundMuted),labelRightColor:n("card","labelRightColor",e.foregroundMuted),labelHighlightRightColor:n("card","labelHighlightRightColor",e.warning),textRightColor:n("card","textRightColor",e.foreground),subtextRightColor:n("card","subtextRightColor",e.foregroundMuted),rowLeftLabel:n("card","rowLeftLabel",e.foregroundMuted),rowRightLabel:n("card","rowRightLabel",e.foreground),iconColor:n("card","iconColor",e.primary),iconBackgroundColor:n("card","iconBackgroundColor",e.primary+"26"),actionColor:n("card","actionColor",e.foregroundMuted),actionIcon:n("card","actionIcon",e.foregroundMuted),descriptionColor:n("card","descriptionColor",e.foregroundMuted),borderRadius:n("card","borderRadius",12),borderWidth:n("card","borderWidth",0),borderColor:n("card","borderColor",e.border),shadowColor:n("card","shadowColor","#000"),shadowOffset:n("card","shadowOffset",{width:0,height:-4}),shadowOpacity:n("card","shadowOpacity",0),shadowRadius:n("card","shadowRadius",12),elevation:n("card","elevation",0),iconContainerBorderRadius:n("card","iconContainerBorderRadius",12),backShadowColor:"transparent",backShadowOffset:{top:4,left:4,right:-4,bottom:-4},backShadowSpacing:8},s=(o?.depositMenu??t?.depositMenu)?.card,a=(o?.transferCrypto??t?.transferCrypto)?.depositAddress?.card,l=(o?.depositCard??t?.depositCard)?.quoteProvider?.card,u=(o?.depositTracker??t?.depositTracker)?.executionRow?.card;return {header:{titleColor:n("header","titleColor",e.foreground),buttonColor:n("header","buttonColor",e.foreground)},card:i,input:{backgroundColor:n("input","backgroundColor",n("search","backgroundColor",e.card)),textColor:n("input","textColor",n("search","inputColor",e.foreground)),placeholderColor:n("input","placeholderColor",n("search","placeholderColor",e.foregroundMuted)),borderColor:n("input","borderColor",e.border),borderRadius:n("input","borderRadius",n("search","borderRadius",8)),borderWidth:n("input","borderWidth",1)},button:{primaryBackground:n("button","primaryBackground",e.primary),primaryText:n("button","primaryText",e.primaryForeground),secondaryBackground:n("button","secondaryBackground",e.card),secondaryText:n("button","secondaryText",e.foreground),borderRadius:n("button","borderRadius",12),borderWidth:n("button","borderWidth",0),borderColor:n("button","borderColor",e.border)},container:{titleColor:n("container","titleColor",e.foreground),subtitleColor:n("container","subtitleColor",e.foregroundMuted),actionColor:n("container","actionColor",e.foregroundMuted),actionTitle:n("container","actionTitle",e.foregroundMuted),buttonColor:n("container","buttonColor",e.primary),buttonTitleColor:n("container","buttonTitleColor",e.primaryForeground),iconBackgroundColor:n("container","iconBackgroundColor",e.success),iconColor:n("container","iconColor",e.foreground)},search:{backgroundColor:n("search","backgroundColor",e.card),inputColor:n("search","inputColor",e.foreground),placeholderColor:n("search","placeholderColor",e.foregroundMuted),borderRadius:n("search","borderRadius",8)},list:{titleSectionColor:n("list","titleSectionColor",e.foregroundMuted),rowBorderRadius:n("list","rowBorderRadius",12)},badge:{borderRadius:n("badge","borderRadius",8)},sheet:{shadowColor:n("sheet","shadowColor","#000"),shadowOffset:n("sheet","shadowOffset",{width:0,height:-4}),shadowOpacity:n("sheet","shadowOpacity",.1),shadowRadius:n("sheet","shadowRadius",12),elevation:n("sheet","elevation",16)},depositMenu:{card:ol(i,s)},transferCrypto:{depositAddress:{card:ol(i,a)}},depositCard:{quoteProvider:{card:ol(i,l)}},depositTracker:{executionRow:{card:ol(i,u)}}}}function qc(e,t,r){let n={...jc[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var Kc=createContext(null);function V(){let e=useContext(Kc);if(!e){let t=$c.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:Zs(t,void 0,"dark"),isDark:true}}return e}function nt({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:i,gradientTo:s}){let{colors:a}=V(),l=i??a.warning,u=s??"#FBBF24",c=useRef(new Animated.Value(0)).current,y=useId(),T=useMemo(()=>`circularProgressGrad_${y.replace(/[^a-zA-Z0-9_-]/g,"")}`,[y]),w=(e-t)/2,m=2*Math.PI*w,g=e/2,h=o??Math.max(0,Math.round(e-t*2-8)),S=(e-h)/2;useEffect(()=>{let p=Animated.loop(Animated.timing(c,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true})),d=requestAnimationFrame(()=>p.start());return ()=>{cancelAnimationFrame(d),p.stop();}},[c]);let b=c.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]});return jsxs(View,{style:[{width:e,height:e},n],children:[jsx(Animated.View,{style:{position:"absolute",top:0,left:0,width:e,height:e,transform:[{rotate:b}]},children:jsxs(Pt,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:T,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:l}),jsx(Stop,{offset:"100%",stopColor:u})]})}),jsx(Circle,{cx:g,cy:g,r:w,stroke:`url(#${T})`,strokeWidth:t,fill:"none",strokeDasharray:`${m*.75} ${m*.25}`,strokeLinecap:"round",rotation:-90,origin:`${g}, ${g}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:S+1.5,left:S,width:h,height:h},children:r}):null]})}function Yc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ji({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Nr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Xs({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function st({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"18",y1:"6",x2:"6",y2:"18",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _r({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Zi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"15 18 9 12 15 6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Gt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function ln({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{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:t,strokeWidth:r,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:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Le({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function ea({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12.01",y2:"16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Gc({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"2",x2:"12",y2:"6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"18",x2:"12",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"4.93",x2:"7.76",y2:"7.76",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"16.24",x2:"19.07",y2:"19.07",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"12",x2:"6",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"18",y1:"12",x2:"22",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"4.93",y1:"19.07",x2:"7.76",y2:"16.24",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16.24",y1:"7.76",x2:"19.07",y2:"4.93",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Do({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function An({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function il({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Vo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})})}function Xi({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function es({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function jr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function sl({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M3 7V5a2 2 0 0 1 2-2h2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 3h2a2 2 0 0 1 2 2v2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M21 17v2a2 2 0 0 1-2 2h-2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M7 21H5a2 2 0 0 1-2-2v-2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M8 14s1.5 2 4 2 4-2 4-2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 9h.01",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M15 9h.01",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function al({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ta({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M5.43 5.43A8.06 8.06 0 0 0 4 10c0 6 8 12 8 12a29.94 29.94 0 0 0 5-5",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M19.18 13.52A8.66 8.66 0 0 0 20 10a8 8 0 0 0-8-8 7.88 7.88 0 0 0-3.52.82",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9.13 9.13A2.78 2.78 0 0 0 9 10a3 3 0 0 0 3 3 2.78 2.78 0 0 0 .87-.13",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function rp({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M11 14h10",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M17 10l4 4-4 4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function op({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:12,cy:5,r:1,stroke:t,strokeWidth:r,fill:t}),jsx(Circle,{cx:12,cy:12,r:1,stroke:t,strokeWidth:r,fill:t}),jsx(Circle,{cx:12,cy:19,r:1,stroke:t,strokeWidth:r,fill:t})]})}function np({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Pt,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Path,{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"16 17 21 12 16 7",stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:21,y1:12,x2:9,y2:12,stroke:t,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ip({height:e=24,color:t="#011e0f"}){let o=e*2.985416666666667;return jsxs(Pt,{width:o,height:e,viewBox:"0 0 71.65 24",fill:"none",children:[jsx(Path,{d:"M36.12,3.68c0-1.13.95-2.04,2.07-2.04s2.07.92,2.07,2.04-.92,2.07-2.07,2.07-2.07-.92-2.07-2.07ZM29.98,1.92h3.6v20.16h-3.6s0-20.16,0-20.16ZM40.01,7.68h-3.63v14.4h3.63V7.68ZM66.1,14.39c2.73-1.68,4.59-4.18,5.32-6.72h-3.63c-.95,2.42-3.12,4.24-5.5,5.01V1.92h-3.63v20.16h3.63v-6c2.77.69,4.96,3.09,5.71,6h3.65c-.56-3.05-2.64-5.91-5.55-7.68ZM46.44,9.29c.95-1.26,2.8-2,4.31-2,2.8,0,5.12,2.05,5.13,5.15v9.63h-3.63v-8.83c0-1.27-.57-2.74-2.4-2.74-2.16,0-3.4,1.92-3.4,4.16v7.43h-3.63V7.69h3.63v1.6Z",fill:t}),jsx(Circle,{cx:12,cy:12,r:12,fill:"#00d66f"}),jsx(Path,{d:"M11.45,4.8h-3.7c.72,3.01,2.82,5.58,5.45,7.2-2.64,1.62-4.73,4.19-5.45,7.2h3.7c.92-2.78,3.46-5.2,6.58-5.7v-3.01c-3.12-.49-5.66-2.91-6.58-5.69Z",fill:"#011e0f"})]})}function ts({children:e,mode:t="auto",accentColor:r,theme:o,fontFamily:n,fonts:i,components:s}){let a=useColorScheme(),l=useMemo(()=>t==="auto"?a==="dark"?"dark":"light":t,[t,a]),u=useMemo(()=>{let w=o?.[l];return qc(l,w,r)},[l,o,r]),c=useMemo(()=>Zs(u,s,l),[u,s,l]),y=useMemo(()=>i?{regular:i.regular||n,medium:i.medium||n,semibold:i.semibold||n,bold:i.bold||n}:n?{regular:n,medium:n,semibold:n,bold:n}:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},[n,i]),T=useMemo(()=>({mode:l,colors:u,fonts:y,components:c,isDark:l==="dark"}),[l,u,y,c]);return jsx(Kc.Provider,{value:T,children:e})}var ia={damping:28,stiffness:300,mass:.8},$h=80,qh=500;function bt({visible:e,onClose:t,children:r,closeOnBackdropPress:o=true,enablePanDownToClose:n=true,showHandle:i=true,heightPercent:s,maxHeightPercent:a,startExpanded:l=false,noPadding:u=false,borderTopLeftRadius:c=24,borderTopRightRadius:y=24}){let{colors:T}=V(),{height:w}=useWindowDimensions(),[m,g]=useState(false),h=useRef(e);h.current=e;let S=useRef(0),b=s!=null&&s>=1,p=b||u?0:Platform.OS==="ios"?34:24,d=a!=null&&s!=null&&a>s,C=s!=null?(d?a:s)*w:void 0,x=d?(a-s)*w:0,_=l?0:x,k=useSharedValue(w),v=useRef(null),M=useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null),h.current||g(false);},[]);useEffect(()=>{e?(v.current&&(clearTimeout(v.current),v.current=null),g(true),k.value=withSpring(_,ia)):m&&(k.value=withTiming(w,{duration:250},j=>{j&&runOnJS(M)();}),v.current=setTimeout(()=>{v.current=null,M();},350));},[e]),useEffect(()=>()=>{v.current&&clearTimeout(v.current);},[]),useEffect(()=>{m&&e&&(k.value=withSpring(_,ia));},[_]);let W=useCallback(()=>{o&&t();},[o,t]),O=useMemo(()=>{if(!(!n&&!d))return PanResponder.create({onStartShouldSetPanResponder:()=>true,onMoveShouldSetPanResponder:()=>true,onPanResponderGrant:()=>{S.current=k.value;},onPanResponderMove:(j,le)=>{if(Math.abs(le.dy)<4)return;let Ye=S.current+le.dy;k.value=Math.max(0,Ye);},onPanResponderRelease:(j,le)=>{if(!(Math.abs(le.dy)<4)){if(n&&(le.dy>$h||le.vy>qh)){t();return}if(d){let Ye=x/2,_e=k.value<Ye?0:x;k.value=withSpring(_e,ia);}else k.value=withSpring(_,ia);}},onPanResponderTerminate:()=>{k.value=withSpring(_,ia);}}).panHandlers},[n,d,x,_,k,t]),F=useAnimatedStyle(()=>({transform:[{translateY:k.value}]})),U=useAnimatedStyle(()=>({opacity:interpolate(k.value,[0,w*.5,w],[.5,.25,0],Extrapolation.CLAMP)}));return m?jsx(Modal,{transparent:true,visible:true,animationType:"none",onRequestClose:t,children:jsxs(View,{style:bi.root,pointerEvents:e?"auto":"none",children:[jsx(ap.View,{style:[bi.backdrop,U],pointerEvents:e?"auto":"none",children:jsx(Pressable,{style:StyleSheet.absoluteFill,onPress:W})}),jsxs(ap.View,{style:[bi.sheet,F,{height:C,backgroundColor:T.background,borderTopLeftRadius:b?0:c,borderTopRightRadius:b?0:y}],children:[jsxs(GestureHandlerRootView,{style:bi.gestureRoot,children:[i&&jsx(View,{style:bi.handleContainer,pointerEvents:"none",children:jsx(View,{style:[bi.handle,{backgroundColor:T.foreground+"33"}]})}),r,p>0&&jsx(View,{style:{height:p}})]}),O&&jsx(View,{...O,style:bi.dragOverlay})]})]})}):null}var bi=StyleSheet.create({root:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject,backgroundColor:"#000"},sheet:{overflow:"hidden"},gestureRoot:{flex:1},handleContainer:{alignItems:"center",paddingTop:10,paddingBottom:4,zIndex:1},dragOverlay:{position:"absolute",top:0,left:0,right:0,height:40,zIndex:2},handle:{width:36,height:5,borderRadius:2.5}}),at=ni__default.forwardRef((e,t)=>jsx(ScrollView,{ref:t,...e}));at.displayName="BottomSheetScrollView";function rs(e){return jsx(FlatList,{...e})}var Kh="https://api.unifold.io",td="__UnifoldDevApiBaseUrl__",Er="pk_test_123",ll={};function Qh(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[td];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function fr(){return Qh()??Kh}function cl(e){if(e.publishableKey!==void 0){if(!e.publishableKey||e.publishableKey.trim()==="")throw new Error("Unifold SDK: publishableKey cannot be empty. Please provide a valid publishable key.");!e.publishableKey.startsWith("pk_test_")&&!e.publishableKey.startsWith("pk_live_")&&console.warn('Unifold SDK: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),Er=e.publishableKey;}e.defaultConfig&&(ll=e.defaultConfig);}function cp(e){if(typeof __DEV__>"u"||!__DEV__){console.warn("[Unifold] setDevApiUrl() is only available in development mode");return}if(typeof globalThis>"u")return;let t=e.trim();t.length>0?globalThis[td]=t:delete globalThis[td];}function sa(){return fr()}function dl(){return Er}function to(e){if(!e||e.trim()==="")throw new Error("Unifold SDK: No publishable key configured. Please provide a valid publishable key via setApiConfig() or pass it directly to the API function.");e==="pk_test_123"&&console.warn('Unifold SDK: Using default test key "pk_test_123". This should only be used for local development. Please use a real publishable key in production.');}function cr(e){let t=e.startsWith("/")?e:`/${e}`;return `${fr()}/api/public${t}`}function oe(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,fr()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${fr()}${e}`:`${fr()}/api/public${e}`:""}async function dn(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||ll.recipientAddress;if(!r)throw new Error("[Unifold] recipient_address is required for createDepositAddress. Pass recipientAddress in your beginDeposit() config.");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||ll.destinationChainId||"8453",destination_token_address:e?.destination_token_address||ll.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||Er;to(n);let i=await fetch(`${fr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok)throw new Error(`Failed to create deposit address: ${i.statusText}`);return await i.json()}function un(e,t){return e.find(r=>r.chain_type===t)}async function pn(e,t,r){let o=t||Er;to(o);let n=await fetch(`${fr()}/v1/public/direct_executions/query`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify({external_user_id:e,...r&&{action_type:r}})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}async function ul(e,t){let r=t||Er;to(r);let o=await fetch(`${fr()}/v1/public/direct_executions/poll`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify({deposit_wallet_id:e})});if(!o.ok)throw new Error(`Failed to poll executions: ${o.statusText}`);return o.json()}function Te(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let r=e.icon_urls.find(o=>o.format===t);return r?r.url:e.icon_url}async function Ci(e,t){let r=e||Er;to(r);let o=`${fr()}/v1/public/tokens/supported_deposit_tokens`;if(t?.destination_token_address&&t?.destination_chain_id&&t?.destination_chain_type){let i=new URLSearchParams({destination_token_address:t.destination_token_address,destination_chain_id:t.destination_chain_id,destination_chain_type:t.destination_chain_type});o=`${o}?${i.toString()}`;}let n=await fetch(o,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch supported deposit tokens: ${n.statusText}`);return n.json()}async function rd(e,t){let r=t||Er;to(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${fr()}/v1/public/tokens/token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch token metadata: ${n.statusText}`);return n.json()}function pl(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function od(e,t){let r=t||Er;to(r);let o=await fetch(`${fr()}/v1/public/onramps/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to fetch onramp quotes: ${o.statusText}`);return o.json()}async function nd(e,t){let r=t||Er;to(r);let o=await fetch(`${fr()}/v1/public/onramps/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":r,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to create onramp session: ${o.statusText}`);return o.json()}async function id(e,t){let r=t||Er;to(r);let o=new URLSearchParams;e.country_code&&o.append("country_code",e.country_code),e.subdivision_code&&o.append("subdivision_code",e.subdivision_code),o.append("token_address",e.token_address),o.append("chain_id",e.chain_id),o.append("chain_type",e.chain_type);let n=await fetch(`${fr()}/v1/public/onramps/default_token?${o.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":r}});if(!n.ok)throw new Error(`Failed to fetch default onramp token: ${n.statusText}`);return n.json()}async function aa(e){let t=e||Er;to(t);let r=await fetch(`${fr()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch fiat currencies: ${r.statusText}`);return r.json()}function os(e,t="png"){if(!e||e.length===0)return;let r=e.find(o=>o.format===t);return r?r.url:e[0]?.url}async function la(e){let t=e||Er;to(t);let r=await fetch(`${fr()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch project config: ${r.statusText}`);return r.json()}async function sd(){let e=await fetch(`${fr()}/v1/public/tokens/chains`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch token chains: ${e.statusText}`);return e.json()}function ml(e,t,r){let o=e.find(i=>i.chain_id===r);if(o)return o.chain_name;let n=e.find(i=>i.chain_type===t);return n?n.chain_name:t.charAt(0).toUpperCase()+t.slice(1)}async function ca(){let e=await fetch(`${fr()}/v1/public/ip_address`,{method:"GET",headers:{accept:"application/json"}});if(!e.ok)throw new Error(`Failed to fetch IP address information: ${e.statusText}`);return e.json()}async function fl(e){let t=e||Er;to(t);let r=await fetch(`${fr()}/v1/public/tokens/supported_destination_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!r.ok)throw new Error(`Failed to fetch supported destination tokens: ${r.statusText}`);return r.json()}async function ad(e,t){let r=t||Er;to(r);let o=await fetch(`${fr()}/v1/public/addresses/verify`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":r},body:JSON.stringify(e)});if(!o.ok)throw new Error(`Failed to verify address: ${o.statusText}`);return o.json()}async function ld(e,t){return ul(e.deposit_wallet_id,t)}async function hl(e,t,r,o,n){let i=n||Er;to(i);let s=await fetch(`${fr()}/v1/public/addresses/balance`,{method:"POST",headers:{"Content-Type":"application/json",accept:"application/json","x-publishable-key":i},body:JSON.stringify({address:e,chain_type:t,chain_id:r,token_address:o})});if(!s.ok)throw new Error(`Failed to fetch address balance: ${s.statusText}`);return s.json()}function up({size:e=28}){return jsx(Pt,{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 mp({size:e=28}){return jsxs(Pt,{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 gp({size:e=28}){return jsxs(Pt,{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 yp({size:e=28}){return jsxs(Pt,{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 bp({size:e=28}){return jsx(Pt,{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 gl=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:up},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:mp},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:gp},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:yp},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:bp}];function yl(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function bl(e,t){let r=parseFloat(e);if(isNaN(r))return e;let o=t.toLowerCase(),n=["eth","btc"].includes(o)?4:2;return r.toFixed(n)}function ss(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=gl.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=gl.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function St({onPress:e,title:t,variant:r="close",leftAction:o}){let{components:n,fonts:i}=V(),s=r==="back",a=s?jsx(Zi,{size:22,color:n.header.buttonColor,strokeWidth:2.5}):jsx(st,{size:20,color:n.header.buttonColor,strokeWidth:2}),l=jsx(TouchableOpacity,{style:En.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:s?"Back":"Close",children:a});return t?jsxs(View,{style:En.headerWithTitle,children:[s?l:o??jsx(View,{style:En.headerSide}),jsx(Text,{style:[En.headerTitleText,{color:n.header.titleColor},...i.bold?[{fontFamily:i.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),s?jsx(View,{style:En.headerSide}):l]}):jsxs(View,{style:s?En.headerWithTitle:En.header,children:[s?l:jsx(View,{style:En.headerSpacer}),!s&&l]})}var Cl={paddingTop:8,paddingBottom:8},En=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...Cl},headerWithTitle:{flexDirection:"row",alignItems:"center",...Cl,zIndex:9999,overflow:"visible"},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 Mr({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=V();return e?jsx(Text,{style:[Cp.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[Cp.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var Cp=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function To({quote:e,label:t,value:r,last:o,hideDivider:n}){return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsx(Text,{style:[e.rowValue],children:r})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}function fd({quote:e,label:t,address:r,last:o,hideDivider:n}){let[i,s]=useState(false),{colors:a,components:l}=V(),u=()=>{Clipboard.setString(r),s(true),setTimeout(()=>s(false),2e3);},c=yl(r);return jsxs(Fragment$1,{children:[jsxs(View,{style:e.row,children:[jsx(Text,{style:e.rowLabel,children:t}),jsxs(View,{style:e.rowRight,children:[jsx(Text,{style:[e.rowValue,{flexShrink:1,minWidth:0}],numberOfLines:1,ellipsizeMode:"middle",selectable:true,children:c}),jsx(TouchableOpacity,{onPress:u,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:i?jsx(Le,{size:14,color:a.success,strokeWidth:2.5}):jsx(ln,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var wl={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function as({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=V(),i=e.toLowerCase(),s=wl[i]??n.primary,a=Math.round(o*.42);return jsxs(View,{style:{width:o,height:o,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:o,height:o,borderRadius:o/2}}):jsx(View,{style:{width:o,height:o,borderRadius:o/2,backgroundColor:s,alignItems:"center",justifyContent:"center"},children:jsx(Text,{style:{color:"#FFFFFF",fontWeight:"700",fontSize:o*.38},children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),r?jsx(Image,{source:{uri:r},style:{position:"absolute",bottom:-2,right:-4,width:a,height:a,borderRadius:a/2,borderWidth:2,borderColor:n.background}}):null]})}function Sl({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:i}){let{colors:s,components:a,fonts:l}=V(),u=cr(`/icons/currencies/png/${e.toLowerCase()}.png`),c=ss(r);return jsxs(View,{style:[mo.diagram,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor},i],children:[jsxs(View,{style:mo.step,children:[jsx(Image,{source:{uri:u},style:mo.iconImage}),jsx(Text,{style:[mo.label,{color:a.card.subtitleColor,fontFamily:l.regular}],children:"You paid"}),jsx(Text,{style:[mo.value,{color:a.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(_r,{size:16,color:s.foregroundMuted,strokeWidth:2}),jsxs(View,{style:mo.step,children:[jsxs(View,{style:mo.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:mo.tokenIcon}):jsx(View,{style:[mo.tokenIcon,{backgroundColor:wl[t.toLowerCase()]??s.primary}]}),n?jsx(Image,{source:{uri:n},style:[mo.networkBadge,{borderColor:s.background}]}):null]}),jsx(Text,{style:[mo.label,{color:a.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[mo.value,{color:a.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",c]})]})]})}var mo=StyleSheet.create({diagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-around",paddingVertical:20,paddingHorizontal:24,width:"100%"},step:{alignItems:"center"},iconImage:{width:24,height:24,borderRadius:12,marginBottom:4},iconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},tokenIcon:{width:24,height:24,borderRadius:12},networkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderRadius:7,borderWidth:2},label:{fontSize:10},value:{fontSize:14,fontWeight:"500",paddingTop:4}});function Wo(){let{colors:e,fonts:t,components:r}=V(),o=r.input,n=r.button,i=r.container,s=r.card,a=r.header;return useMemo(()=>{let l=s.borderRadius,u={flex:{flex:1},screen:{flex:1,backgroundColor:e.background,paddingHorizontal:24,paddingBottom:16},content:{flex:1,paddingTop:16},title:{fontSize:18,color:a.titleColor,marginBottom:8,...t.bold?{fontFamily:t.bold}:{}},subtitle:{fontSize:15,color:e.foregroundMuted,marginBottom:36,lineHeight:22,...t.regular?{fontFamily:t.regular}:{}},fieldWrap:{marginBottom:20},fieldLabel:{fontSize:14,color:e.foregroundSubtle,marginBottom:8,...t.semibold?{fontFamily:t.semibold}:{}},input:{backgroundColor:o.backgroundColor,borderRadius:o.borderRadius,padding:16,fontSize:17,color:o.textColor,borderWidth:o.borderWidth,borderColor:o.borderColor,...t.regular?{fontFamily:t.regular}:{}},hint:{fontSize:12,color:e.foregroundSubtle,marginTop:8,...t.regular?{fontFamily:t.regular}:{}},emailRow:{flexDirection:"row",alignItems:"center",gap:6,marginTop:4,backgroundColor:e.card,paddingHorizontal:14,paddingVertical:10,borderRadius:Math.min(l,12)},emailLabel:{fontSize:13,color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},emailValue:{fontSize:13,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},footer:{gap:4},continueBtn:{backgroundColor:i.buttonColor,borderRadius:n.borderRadius,paddingVertical:18,alignItems:"center"},continueBtnDisabled:{backgroundColor:e.card},continueBtnText:{color:i.buttonTitleColor,fontSize:17,...t.bold?{fontFamily:t.bold}:{}},continueBtnTextDisabled:{color:e.foregroundSubtle,...t.regular?{fontFamily:t.regular}:{}},ghostBtn:{paddingVertical:16,alignItems:"center"},ghostBtnText:{color:e.foregroundMuted,fontSize:15,...t.medium?{fontFamily:t.medium}:{}},loaderInButton:{justifyContent:"center",alignItems:"center"}},c={amountContainer:{flex:1,alignItems:"center",justifyContent:"center",gap:8},amountText:{fontSize:64,color:e.foreground,letterSpacing:-2,minWidth:80,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},amountPlaceholder:{color:e.foregroundSubtle},currencyLabel:{fontSize:15,color:e.foregroundMuted,letterSpacing:1,...t.medium?{fontFamily:t.medium}:{}},minAmountText:{fontSize:13,textAlign:"center",marginTop:8,...t.regular?{fontFamily:t.regular}:{}},quickRow:{flexDirection:"row",gap:10,marginBottom:12},quickPill:{flex:1,paddingVertical:12,alignItems:"center",borderRadius:s.borderRadius,backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:s.borderColor},quickPillText:{fontSize:14,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},numpad:{gap:4,marginBottom:12},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:56,alignItems:"center",justifyContent:"center",marginHorizontal:4},numpadKeyText:{fontSize:28,color:e.foreground,...t.regular?{fontFamily:t.regular}:{}},backspaceText:{fontSize:22,color:e.foregroundMuted,...t.regular?{fontFamily:t.regular}:{}},paymentRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:10,borderRadius:999,backgroundColor:"transparent",alignSelf:"flex-start",marginBottom:12},paymentRowHeader:{flexDirection:"row",alignItems:"center",paddingVertical:10,paddingHorizontal:16,borderRadius:s.borderRadius,backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:s.borderColor,alignSelf:"center"},paymentLeft:{flexDirection:"row",alignItems:"center",gap:6},applePayIcon:{fontSize:20,color:e.foreground},paymentLabel:{fontSize:15,color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},paymentHint:{fontSize:13,color:e.foregroundMuted,marginLeft:12,...t.regular?{fontFamily:t.regular}:{}},inlineError:{fontSize:13,color:e.error,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},inlineStatus:{fontSize:13,color:e.foregroundMuted,textAlign:"center",marginTop:10,paddingHorizontal:16,...t.regular?{fontFamily:t.regular}:{}},sheetContent:{flex:1,paddingHorizontal:24,paddingTop:8,gap:12},sheetHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:4},sheetBackBtn:{width:32,height:32,borderRadius:16,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:s.borderWidth,borderColor:e.border},sheetTitleRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},sheetCloseBtn:{width:28,height:28,borderRadius:14,backgroundColor:e.card,alignItems:"center",justifyContent:"center",borderWidth:s.borderWidth,borderColor:e.border},sheetTitle:{fontSize:18,color:e.foreground,...t.bold?{fontFamily:t.bold}:{}},sheetOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:e.border},sheetOptionLeft:{flex:1,flexDirection:"row",alignItems:"center",gap:12},sheetOptionIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},sheetOptionLabel:{fontSize:16,color:e.foreground,...t.medium?{fontFamily:t.medium}:{}},sheetOptionHint:{fontSize:13,color:e.foregroundMuted,marginTop:2,...t.regular?{fontFamily:t.regular}:{}},sheetLoading:{alignItems:"center",paddingVertical:32,gap:12},sheetStatusText:{fontSize:15,color:e.foregroundMuted,textAlign:"center",...t.regular?{fontFamily:t.regular}:{}},sheetError:{flex:1,justifyContent:"center",paddingVertical:20},sheetErrorText:{fontSize:14,color:e.error,textAlign:"center",lineHeight:20,...t.regular?{fontFamily:t.regular}:{}},addPaymentBtn:{marginTop:12,paddingVertical:14,borderRadius:Math.min(l,14),backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:e.border,alignItems:"center",justifyContent:"center"},addPaymentBtnText:{fontSize:15,color:e.primary,...t.semibold?{fontFamily:t.semibold}:{}}},y={heroBox:{backgroundColor:s.backgroundColor,borderRadius:l,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",...t.semibold?{fontFamily:t.semibold}:{}},heroAmount:{fontSize:48,color:e.foreground,letterSpacing:-1,...t.bold?{fontFamily:t.bold}:{}},heroCurrency:{fontSize:22,color:e.primary,...t.medium?{fontFamily:t.medium}:{}},heroNetwork:{fontSize:15,color:e.foregroundSubtle,marginTop:2,...t.medium?{fontFamily:t.medium}:{}},card:{backgroundColor:s.backgroundColor,borderRadius:l,borderWidth:s.borderWidth,borderColor:s.borderColor,overflow:"hidden",marginBottom:12,marginTop:16},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,...t.regular?{fontFamily:t.regular}:{}},rowValue:{fontSize:14,fontWeight:"500",color:s.rowRightLabel,...t.medium?{fontFamily:t.medium}:{}}},T=Math.max(16,Math.min(l,22)),w={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:s.borderWidth,borderColor:e.border,paddingHorizontal:16,paddingVertical:16},swapCardTop:{borderTopLeftRadius:T,borderTopRightRadius:T,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:T,borderBottomRightRadius:T,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,...t.regular?{fontFamily:t.regular}:{}},swapReceivePrimary:{fontSize:40,color:e.foreground,letterSpacing:-1,...t.regular?{fontFamily:t.regular}:{}},swapReceiveSub:{fontSize:13,color:e.foregroundMuted,marginTop:4,...t.regular?{fontFamily:t.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,...t.semibold?{fontFamily:t.semibold}:{}},payHint:{fontSize:15,color:e.foregroundMuted,textAlign:"center",marginBottom:18,marginTop:4,...t.regular?{fontFamily:t.regular}:{}},summaryLabel:{fontSize:12,color:e.foregroundSubtle,textTransform:"uppercase",letterSpacing:.3,...t.semibold?{fontFamily:t.semibold}:{}},applePayBtn:{backgroundColor:n.secondaryBackground,borderRadius:n.borderRadius,borderWidth:n.borderWidth>0?n.borderWidth:1,borderColor:n.borderWidth>0?n.borderColor:e.border,paddingVertical:18,alignItems:"center",marginBottom:10},applePayBtnText:{color:n.secondaryText,fontSize:17,...t.bold?{fontFamily:t.bold}:{}}},m={input:{fontSize:14,...t.regular?{fontFamily:t.regular}:{}},list:{gap:8},row:{flexDirection:"row",alignItems:"center",paddingVertical:14,paddingHorizontal:16,borderRadius:Math.min(l,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,...t.medium?{fontFamily:t.medium}:{}},rowTextSelected:{color:e.foreground,...t.semibold?{fontFamily:t.semibold}:{}},checkCircle:{width:24,height:24,borderRadius:12,backgroundColor:e.primary,alignItems:"center",justifyContent:"center"}},g={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:a.titleColor,textAlign:"center",marginBottom:10,...t.bold?{fontFamily:t.bold}:{}},sub:{fontSize:15,color:e.foregroundMuted,textAlign:"center",lineHeight:22,marginBottom:36,...t.regular?{fontFamily:t.regular}:{}},successScrollContent:{flexGrow:1,width:"100%",alignItems:"center",paddingBottom:24},detailCard:{width:"100%"}};return {form:u,quote:y,pm:w,wallet:m,flow:g,amount:c}},[e,t,o,n,i,s,a])}var kp="",Tp;function kl(e){kp=e;}function Tl(e){Tp=e;}function $r(){let e=kp||dl();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function qr(){return Tp??sa()}async function xl(){let e=`${qr()}/v1/public/onramps/headless/stripe/config`,t=$r(),r=await fetch(e,{method:"GET",headers:{"x-publishable-key":t,"Content-Type":"application/json"}});if(!r.ok)throw new Error(`Failed to load Stripe config: ${r.status}`);let o=await r.json();if(!o?.publishable_key)throw new Error("Missing Stripe publishable key in config response");return o.publishable_key}async function hd(e){let t=await fetch(`${qr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":$r(),"Content-Type":"application/json"},body:JSON.stringify({email:e})});if(!t.ok)throw new Error(`Failed to create auth intent: ${t.status}`);let r=await t.json();return r.auth_intent_id??r.id}async function xp(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":$r(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e,...t&&{crypto_customer_id:t}})});if(!r.ok)throw new Error(`Failed to exchange auth intent for tokens: ${r.status}`);return r.json()}async function gd(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":$r(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e,...t&&{crypto_customer_id:t}})}),o=await r.json().catch(()=>({}));if(!r.ok)throw new Error(o?.message??`Failed to refresh OAuth token: ${r.status}`);return o}async function _p(e,t){let r={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},o=await fetch(`${qr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":$r(),"x-stripe-oauth-token":t,"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await o.text();if(!o.ok)throw new Error(`Failed to create onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function Rp(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":$r(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}}),o=await r.text();if(!r.ok)throw new Error(`Failed to confirm onramp session: ${r.status} ${o}`);return JSON.parse(o)}async function Mn(e,t){let r=`${qr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":$r(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp customer: ${o.status} ${n}`);return JSON.parse(n)}async function vp(e){let t=`${qr()}/v1/public/onramps/headless/stripe/sessions`,r=await fetch(t,{method:"GET",headers:{"x-publishable-key":$r(),"x-stripe-oauth-token":e}}),o=await r.text();if(!r.ok)throw new Error(`Failed to list onramp sessions: ${r.status} ${o}`);return JSON.parse(o)}async function Ip(e,t){let r=`${qr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":$r(),"x-stripe-oauth-token":t}}),n=await o.text();if(!o.ok)throw new Error(`Failed to get onramp session: ${o.status} ${n}`);return JSON.parse(n)}async function yd(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":$r(),"x-stripe-oauth-token":t,"Content-Type":"application/json"}});if(!r.ok){let o=await r.text();throw new Error(`Failed to refresh quote: ${r.status} ${o}`)}return r.json()}async function bd(e){let t=new URLSearchParams({destinationNetwork:e.destinationNetwork,walletAddress:e.walletAddress});e.destinationTag&&t.set("destinationTag",e.destinationTag),e.cryptoCustomerId&&t.set("crypto_customer_id",e.cryptoCustomerId);let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":$r(),"x-stripe-oauth-token":e.accessToken}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch transaction limits: ${r.status} ${o}`)}return r.json()}async function Cd(e,t){let r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":$r(),"x-stripe-oauth-token":t}});if(!r.ok){let o=await r.text();throw new Error(`Failed to fetch payment tokens: ${r.status} ${o}`)}return r.json()}async function Pp(e){if(!e.recipient_address)throw new Error("[Unifold] recipient_address is required for fetchDepositAddress. Pass recipientAddress in your onramp config.");let t={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:{}},r=await fetch(`${qr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":$r(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!r.ok)throw new Error(`Failed to create deposit address: ${r.status}`);return r.json()}function zn(e,t){if(e?.length){let r=e.find(n=>n.format==="png");if(r)return r.url;let o=e.find(n=>n.format==="svg");if(o)return o.url}return t}async function Op(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${qr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":$r()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}function Sg({size:e=24}){let t=e,r=e*(471/750);return jsxs(Pt,{width:t,height:r,viewBox:"0 0 750 471",children:[jsx(Rect,{width:"750",height:"471",rx:"40",fill:"#1A1F71"}),jsx(Path,{fill:"#FFFFFF",d:"M278.198,334.228l33.36-195.763h53.358l-33.384,195.763H278.198z"}),jsx(Path,{fill:"#FFFFFF",d:"M524.307,142.687c-10.57-3.966-27.135-8.222-47.822-8.222c-52.725,0-89.863,26.551-90.18,64.604c-0.297,28.129,26.514,43.821,46.754,53.185c20.77,9.597,27.752,15.716,27.652,24.283c-0.133,13.123-16.586,19.116-31.924,19.116c-21.355,0-32.701-2.967-50.225-10.274l-6.877-3.112l-7.488,43.823c12.463,5.466,35.508,10.199,59.438,10.445c56.09,0,92.502-26.248,92.916-66.884c0.199-22.27-14.016-39.216-44.801-53.188c-18.65-9.056-30.072-15.099-29.951-24.269c0-8.137,9.668-16.838,30.559-16.838c17.447-0.271,30.088,3.534,39.936,7.5l4.781,2.259L524.307,142.687"}),jsx(Path,{fill:"#FFFFFF",d:"M661.615,138.464h-41.23c-12.773,0-22.332,3.486-27.941,16.234l-79.244,179.402h56.031c0,0,9.16-24.121,11.232-29.418c6.123,0,60.555,0.084,68.336,0.084c1.596,6.854,6.492,29.334,6.492,29.334h49.512L661.615,138.464z M596.198,264.872c4.414-11.279,21.26-54.724,21.26-54.724c-0.314,0.521,4.381-11.334,7.074-18.684l3.607,16.878c0,0,10.217,46.729,12.352,56.527h-44.293V264.872z"}),jsx(Path,{fill:"#FFFFFF",d:"M45.879,138.465l-0.682,4.073c21.093,5.106,39.932,12.496,56.426,21.689l47.346,169.688h56.455l83.004-195.45h-56.526l-52.238,133.496l-5.564-27.131c-0.261-0.838-0.544-1.678-0.834-2.52L156.106,154.992c-3.229-12.396-12.597-16.095-24.186-16.528H45.879z"})]})}function kg({size:e=24}){return jsx(Pt,{width:e,height:e,viewBox:"0 0 24 24",children:jsxs(G,{fill:"none",fillRule:"evenodd",children:[jsx(Circle,{cx:"7",cy:"12",r:"7",fill:"#EA001B"}),jsx(Circle,{cx:"17",cy:"12",r:"7",fill:"#FFA200",fillOpacity:.8})]})})}function Tg({size:e=24}){return jsx(Pt,{width:e,height:e,viewBox:"0 0 1152 1152",children:jsxs(G,{transform:"matrix(1.3333333,0,0,-1.3333333,0,1152)",children:[jsx(Path,{fill:"#006FCF",d:"M 0,0 H 863.998 V 864 H 0 Z"}),jsx(G,{transform:"translate(312.9867,136.7145)",children:jsx(Path,{fill:"#FFFFFF",d:"m 0,0 341.634,-0.725 53.654,59.858 54.038,-59.632 h 101.685 v 87.332 l -63.687,68.682 63.687,68.059 V 309.09 L 0,309.585 Z"})}),jsx(G,{transform:"translate(349.7917,170.655)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"m 0,0 v 241.575 h 204.832 v -55.65 H 66.318 V 148.15 H 201.529 V 93.423 H 66.318 V 56.319 H 204.832 V 10e-4 Z"})}),jsx(G,{transform:"translate(780.0408,412.227)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 -69.456,-76.568 -138.713,0 h -87.729 l 113.343,-120.647 -113.341,-120.925 h 85.343 l 69.764,77.335 70.487,-77.335 h 84.803 v 3.43 L -26.971,-120.647 83.957,-1.903 V 0 Z"})}),jsx(G,{transform:"translate(738.7857,721.0845)",children:jsx(Path,{fill:"#FFFFFF",d:"M 0,0 -28.373,-79.366 -56.65,0 H -220.625 V -105.93 L -267.278,0 H -400.1 l -136.414,-309.586 h 661.726 l 0,309.586 z"})}),jsx(G,{transform:"translate(373.0462,548.583)",children:jsx(Path,{fill:"#006FCF",fillRule:"evenodd",d:"M 0,0 32.145,76.837 64.268,0 Z m -9.212,138.867 -107.187,-241.37 h 73.518 l 20.22,48.332 H 86.914 l 20.207,-48.332 h 75.345 L 75.723,138.867 Z"})}),jsx(G,{transform:"translate(554.5071,446.121)",children:jsx(Path,{fill:"#006FCF",d:"M 0,0 64.997,-0.001 V 165.796 L 126.661,-0.001 h 58.418 L 245.49,165.233 V -0.564 l 64,0.563 V 241.368 H 210.032 L 156.513,92.624 103.342,241.012 0,241.369 Z"})})]})})}function Sd({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(Ji,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(Sg,{size:t}):o.includes("mastercard")?jsx(kg,{size:t}):o.includes("amex")||o.includes("american express")?jsx(Tg,{size:t}):jsx(Ji,{size:t*.75,color:r,strokeWidth:1.75})}function _l(e){if(!e)return "";let t=new Date(e*1e3);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:true})}var Td={initialized:"Initialized",requires_payment:"Awaiting Payment",fulfillment_processing:"Processing",fulfillment_complete:"Complete",rejected:"Rejected"};function xd(e,t){switch(e){case "fulfillment_complete":return t.success;case "fulfillment_processing":case "requires_payment":return t.warning;case "rejected":return t.error;default:return t.foregroundMuted}}function Bp({status:e,colors:t,fontFamily:r}){let o=xd(e,t);return jsx(View,{style:{paddingHorizontal:8,paddingVertical:2,borderRadius:6,backgroundColor:o+"20"},children:jsx(Text,{style:{fontSize:11,color:o,fontFamily:r},children:Td[e]??e})})}function Wp({count:e=4}){let{colors:t,components:r}=V(),o=useRef(new Animated.Value(.5)).current,n=t.cardHover??t.border,i=Math.min(r.card.borderRadius??12,14);return useEffect(()=>{let s=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return s.start(),()=>s.stop()},[o]),jsx(View,{style:ls.list,children:Array.from({length:e}).map((s,a)=>jsxs(View,{style:[ls.row,{backgroundColor:t.card,borderRadius:i,borderWidth:r.card.borderWidth,borderColor:t.border}],children:[jsxs(View,{style:ls.left,children:[jsx(Animated.View,{style:[ls.amountBar,{backgroundColor:n,opacity:o}]}),jsx(Animated.View,{style:[ls.subtitleBar,{backgroundColor:n,opacity:o}]})]}),jsx(Animated.View,{style:[ls.badgeBar,{backgroundColor:n,opacity:o}]})]},a))})}var ls=StyleSheet.create({list:{gap:8},row:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:14,paddingHorizontal:16},left:{flex:1,gap:6},amountBar:{height:16,width:"40%",borderRadius:8},subtitleBar:{height:12,width:"55%",borderRadius:6},badgeBar:{height:20,width:80,borderRadius:6,marginLeft:12}});function Ap({active:e,interval:t=15e3,color:r}){let o=useRef(new Animated.Value(0)).current;return useEffect(()=>{if(!e){o.setValue(0);return}let n=()=>{o.setValue(0),Animated.timing(o,{toValue:1,duration:t,useNativeDriver:false}).start(({finished:i})=>{i&&n();});};return n(),()=>o.stopAnimation()},[e,t,o]),e?jsx(View,{style:{height:2,borderRadius:1,overflow:"hidden",opacity:.5},children:jsx(Animated.View,{style:{height:2,borderRadius:1,backgroundColor:r,width:o.interpolate({inputRange:[0,1],outputRange:["0%","100%"]})}})}):null}function Ep({session:e,onBack:t}){let{colors:r,components:o,fonts:n}=V(),[i,s]=useState(false),a=()=>{Clipboard.setString(e.id),s(true),setTimeout(()=>s(false),2e3);},l=e.transaction_details,u=e.status!=="fulfillment_complete"&&e.status!=="rejected",c=xd(e.status,r),y=l?.source_amount?`$${parseFloat(l.source_amount).toFixed(2)}`:"\u2014",T=l?.destination_amount?parseFloat(l.destination_amount).toFixed(2):"\u2014",w=(l?.destination_currency??"").toUpperCase(),m=e.destination_token_metadata,g=zn(m?.icon_urls,m?.icon_url),h=ss(l?.destination_network??""),S=l?.wallet_address?yl(l.wallet_address):null,b=l?.fees?.network_fee_amount?`$${parseFloat(l.fees.network_fee_amount).toFixed(2)}`:null,p=l?.fees?.transaction_fee_amount?`$${parseFloat(l.fees.transaction_fee_amount).toFixed(2)}`:null,d=e.payment_method?e.payment_method.replace(/_/g," ").replace(/\b\w/g,x=>x.toUpperCase()):null,C=[{label:"Amount",value:y},{label:"Received",value:`${T} ${w}`},...d?[{label:"Payment",value:d}]:[],{label:"Network",value:h},...S?[{label:"Wallet",value:S}]:[],...b?[{label:"Network Fee",value:b}]:[],...p?[{label:"Transaction Fee",value:p}]:[]];return jsxs(Fragment,{children:[jsx(View,{style:{paddingLeft:16,paddingTop:8},children:jsx(St,{onPress:t,title:"Purchase Details",variant:"back"})}),jsxs(at,{style:wr.scroll,contentContainerStyle:wr.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:wr.iconSection,children:[jsxs(View,{style:{marginBottom:12,width:64,height:64},children:[jsx(as,{currency:w||"USD",tokenIconUrl:g,size:64}),jsx(View,{style:[wr.statusBadge,{backgroundColor:c,borderColor:o.card.backgroundColor??r.background}],children:u?jsx(Nr,{size:14,color:"#FFFFFF",strokeWidth:2.5}):e.status==="rejected"?jsx(st,{size:14,color:"#FFFFFF",strokeWidth:2.5}):jsx(Le,{size:14,color:"#FFFFFF",strokeWidth:2.5})})]}),jsxs(View,{style:wr.statusRow,children:[jsx(View,{style:[wr.statusDot,{backgroundColor:c}]}),jsx(Text,{style:[wr.statusText,{color:o.container.titleColor,fontFamily:n.semibold}],children:Td[e.status]??e.status})]}),e.created?jsx(Text,{style:[wr.dateText,{color:o.container.subtitleColor,fontFamily:n.regular}],children:_l(e.created)}):null]}),jsxs(View,{style:[wr.card,{backgroundColor:o.card.backgroundColor,borderRadius:o.card.borderRadius,borderWidth:o.card.borderWidth,borderColor:o.card.borderColor}],children:[jsxs(View,{style:wr.cardRow,children:[jsx(Text,{style:[wr.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:"ID"}),jsxs(TouchableOpacity$1,{onPress:a,activeOpacity:.7,style:{flexDirection:"row",alignItems:"center",gap:6,flexShrink:1},children:[jsx(Text,{style:[wr.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium,fontSize:12}],numberOfLines:1,children:e.id.length>12?e.id.slice(0,12)+"\u2026":e.id}),i?jsx(Le,{size:14,color:r.primary,strokeWidth:2}):jsx(ln,{size:14,color:r.foregroundMuted,strokeWidth:2})]})]}),C.map(x=>jsx(ni__default.Fragment,{children:jsxs(View,{style:wr.cardRow,children:[jsx(Text,{style:[wr.cardLabel,{color:o.card.rowLeftLabel,fontFamily:n.regular}],children:x.label}),jsx(Text,{style:[wr.cardValue,{color:o.card.rowRightLabel,fontFamily:n.medium}],selectable:true,children:x.value})]})},x.label))]}),l?.last_error?jsx(View,{style:[wr.card,{backgroundColor:r.errorBackground,borderRadius:o.card.borderRadius}],children:jsxs(View,{style:wr.cardRow,children:[jsx(Text,{style:[wr.cardLabel,{color:r.error,fontFamily:n.regular}],children:"Error"}),jsx(Text,{style:[wr.cardValue,{color:r.error,fontFamily:n.medium,flex:1,textAlign:"right"}],selectable:true,children:l.last_error})]})}):null]})]})}var wr=StyleSheet.create({scroll:{flex:1,paddingTop:8},scrollContent:{paddingHorizontal:24,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},statusBadge:{position:"absolute",bottom:-4,right:-4,width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center",borderWidth:2},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14,marginBottom:2},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"}});function zp({onSelect:e,showKycOption:t=true}){let{colors:r,fonts:o,components:n}=V(),[i,s]=useState(false),a=l=>{s(false),e(l);};return jsxs(View,{style:Eo.wrapper,children:[jsx(TouchableOpacity,{style:Eo.trigger,onPress:()=>s(l=>!l),hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"More options",children:jsx(op,{size:20,color:r.foreground,strokeWidth:2})}),i&&jsxs(Fragment,{children:[jsx(Pressable,{style:Eo.backdrop,onPress:()=>s(false)}),jsxs(View,{style:[Eo.menu,{backgroundColor:n.card.backgroundColor,borderRadius:n.card.borderRadius??12,borderWidth:n.card.borderWidth,borderColor:n.card.borderColor,...Platform.select({ios:{shadowColor:"#000",shadowOffset:{width:0,height:4},shadowOpacity:.15,shadowRadius:12},android:{elevation:8}})}],children:[jsxs(TouchableOpacity,{style:Eo.menuItem,onPress:()=>a("history"),activeOpacity:.6,children:[jsx(Nr,{size:18,color:r.foreground,strokeWidth:1.8}),jsx(Text,{style:[Eo.menuLabel,{color:r.foreground,fontFamily:o.regular}],children:"Purchase History"})]}),t&&jsxs(TouchableOpacity,{style:Eo.menuItem,onPress:()=>a("kyc"),activeOpacity:.6,children:[jsx(jr,{size:18,color:r.foreground,strokeWidth:1.8}),jsx(Text,{style:[Eo.menuLabel,{color:r.foreground,fontFamily:o.regular}],children:"Increase Limits (KYC)"})]}),jsxs(TouchableOpacity,{style:Eo.menuItem,onPress:()=>a("logout"),activeOpacity:.6,children:[jsx(np,{size:18,color:r.error,strokeWidth:1.8}),jsx(Text,{style:[Eo.menuLabel,{color:r.error,fontFamily:o.regular}],children:"Disconnect Stripe Link"})]})]})]})]})}var Eo=StyleSheet.create({wrapper:{zIndex:9999},trigger:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},backdrop:{position:"absolute",top:-500,left:-500,width:2e3,height:2e3,zIndex:9998},menu:{position:"absolute",top:32,left:0,minWidth:200,paddingVertical:6,zIndex:9999},menuItem:{flexDirection:"row",alignItems:"center",paddingHorizontal:14,paddingVertical:12,gap:12},menuLabel:{fontSize:15}});var Ag=[50,100,500],Eg=[["1","2","3"],["4","5","6"],["7","8","9"],[".","0","\u232B"]];function Hp(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Mg(e){return e.card?`${Hp(e.card.brand)} ${Hp(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Pl({initialAmount:e="",currency:t="USD",applePaySupported:r=false,hideQuickAmounts:o=false,minAmount:n,maxAmount:i,paymentSelectorPosition:s="inline",onCollectPayment:a,paymentLoading:l=false,paymentStatus:u,paymentError:c,paymentTokens:y=[],onAddPaymentMethod:T,onConfirm:w,onCancel:m,sheetBorderTopLeftRadius:g,sheetBorderTopRightRadius:h,accessToken:S,showHistoryProgressBar:b=true,onLogout:p,onRequestKYC:d}){let C=Wo(),{colors:x,components:_,fonts:k}=V(),v=g??_.card.borderRadius,M=h??_.card.borderRadius,[W,O]=useState(e),[F,U]=useState(r?"apple_pay":y.length>0?y[0].id:null),j=useRef(false),le=I=>{j.current=true,U(I);};useEffect(()=>{j.current||r||y.length>0&&U(y[0].id);},[y,r]);let[Ye,_e]=useState(false),[ne,we]=useState("select"),[fe,Pe]=useState(null),$e=useRef(false);useEffect(()=>{l&&u&&/saving/i.test(u)&&we("card");},[l,u]);let ue=i,J=ue!=null&&ue>0,be=useMemo(()=>{if(o)return [];let I=Ag.map(D=>({label:`$${D}`,amount:String(D),disabled:false}));return I.push({label:"MAX",amount:J?String(ue):"0",disabled:!J}),I},[o,J,ue]),vt=I=>{if(I==="\u232B"){O(D=>D.slice(0,-1));return}if(I==="."){if(W.includes("."))return;O(D=>D===""?"0.":D+".");return}O(D=>{let q=D.indexOf(".");return q!==-1&&D.length-q>2?D:D==="0"&&I!=="."?I:D+I});},ve=W===""?"0":W,qe=parseFloat(W),Ne=n!=null&&!isNaN(qe)&&qe>0&&qe<n,Ve=ue!=null&&ue>0&&!isNaN(qe)&&qe>ue,ze=W!==""&&!isNaN(qe)&&qe>0&&!Ne&&!Ve,it=r||y.length>0,ie=s==="header",pe=useMemo(()=>{let I=[];r&&I.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let D of y)I.push({id:D.id,label:Mg(D),hint:D.card?`Expires ${D.card.exp_month}/${D.card.exp_year}`:D.type,brand:D.card?.brand,isApplePay:false});return I},[r,y]),et=pe.find(I=>I.id===F),Ke=F!=null&&F!=="apple_pay",$t=et?et.label:Ke&&fe?fe:Ke?"Card":"Pay With",Ee=et?!et.isApplePay:Ke,Oe=et?.brand??fe??void 0,[ar,he]=useState(false),[X,Ce]=useState([]),[pt,It]=useState(false),[me,je]=useState(null),[Vt,ot]=useState(null),Lt=useRef(null);Lt.current=Vt;let Bt=useRef(false);Bt.current=ar;let yt=useCallback(async(I=false)=>{if(S){I||(It(true),je(null));try{let D=await vp(S);if(!Bt.current)return;let q=Array.isArray(D.data)?D.data:Array.isArray(D)?D:[];Ce(q),I||je(null);let Fe=Lt.current?.id;if(Fe){let ke=q.find(pr=>pr.id===Fe);ke&&ot(ke);}}catch(D){if(!Bt.current)return;I||je(D?.message??"Failed to load history");}finally{!I&&Bt.current&&It(false);}}},[S]),Se=useCallback(()=>{he(true),yt();},[yt]);useEffect(()=>{if(!ar||!S)return;let I=setInterval(()=>yt(true),15e3);return ()=>clearInterval(I)},[ar,S,yt]);let Z=useCallback(I=>{switch(I){case "history":Se();break;case "kyc":d?.();break;case "logout":p?.();break}},[Se,d,p]),Q=S?jsx(zp,{onSelect:Z,showKycOption:!!d}):void 0,L=it?jsx(TouchableOpacity,{style:[ie?C.amount.paymentRowHeader:C.amount.paymentRow,l&&{opacity:.5}],onPress:()=>{l||(we("select"),_e(true));},activeOpacity:.7,disabled:l,children:jsxs(View,{style:C.amount.paymentLeft,children:[et?.isApplePay?jsx(Text,{style:C.amount.applePayIcon,children:"\uF8FF"}):Ee?jsx(Sd,{sublabel:Oe,size:20}):null,jsx(Text,{style:C.amount.paymentLabel,children:$t}),jsx(Gt,{size:12,color:C.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:C.form.screen,children:[jsx(St,{onPress:m,title:"Enter amount",leftAction:Q}),ie&&L,jsxs(View,{style:C.form.content,children:[jsxs(View,{style:C.amount.amountContainer,children:[jsxs(Text,{style:[C.amount.amountText,ve==="0"&&C.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",ve]}),jsx(Text,{style:C.amount.currencyLabel,children:t.toUpperCase()}),Ne&&n!=null&&jsxs(Text,{style:[C.amount.minAmountText,{color:x.warning}],children:["Minimum amount is $",n.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})," ",t.toUpperCase()]}),Ve&&ue!=null&&jsxs(Text,{style:[C.amount.minAmountText,{color:x.warning}],children:["Maximum amount is $",ue.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})," ",t.toUpperCase()]})]}),!ie&&L,be.length>0&&jsx(View,{style:C.amount.quickRow,children:be.map(I=>{let D=!I.disabled&&W===I.amount&&W!=="";return jsx(TouchableOpacity,{style:[C.amount.quickPill,D&&{backgroundColor:x.primary},I.disabled&&{opacity:.4}],activeOpacity:.7,disabled:I.disabled||l,onPress:()=>O(I.amount),children:jsx(Text,{style:[C.amount.quickPillText,D&&{color:x.primaryForeground}],children:I.label})},I.label)})}),jsx(View,{style:C.amount.numpad,children:Eg.map((I,D)=>jsx(View,{style:C.amount.numpadRow,children:I.map(q=>jsx(TouchableOpacity,{style:[C.amount.numpadKey,l&&{opacity:.3}],onPress:()=>vt(q),activeOpacity:.6,disabled:l,children:jsx(Text,{style:q==="\u232B"?C.amount.backspaceText:C.amount.numpadKeyText,children:q})},q))},D))}),jsx(TouchableOpacity,{style:[C.form.continueBtn,(!ze||l)&&C.form.continueBtnDisabled],onPress:()=>ze&&!l&&w(W,F),disabled:!ze||l,children:l?jsx(ActivityIndicator,{size:"small",color:x.primaryForeground}):jsx(Text,{style:[C.form.continueBtnText,!ze&&C.form.continueBtnTextDisabled],children:"Continue"})}),!Ye&&c?jsx(Text,{style:C.amount.inlineError,children:c}):!Ye&&l&&u&&__DEV__?jsx(Text,{style:C.amount.inlineStatus,children:u}):null]}),jsx(bt,{visible:Ye,onClose:()=>{l||(_e(false),we("select"));},closeOnBackdropPress:!l,enablePanDownToClose:!l,showHandle:!l,heightPercent:.44,maxHeightPercent:.9,borderTopLeftRadius:v,borderTopRightRadius:M,children:jsx(View,{style:C.amount.sheetContent,children:ne==="select"?jsxs(Fragment,{children:[jsxs(View,{style:C.amount.sheetTitleRow,children:[jsx(Text,{style:C.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity$1,{onPress:()=>_e(false),activeOpacity:.7,style:C.amount.sheetCloseBtn,children:jsx(st,{size:16,color:x.foregroundMuted,strokeWidth:2.5})})]}),jsxs(at,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[pe.map(I=>{let D=F===I.id;return jsxs(TouchableOpacity$1,{style:[C.amount.sheetOption,D&&{borderColor:x.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{le(I.id),Pe(I.isApplePay?null:I.label),_e(false);},children:[jsxs(View,{style:C.amount.sheetOptionLeft,children:[jsx(View,{style:C.amount.sheetOptionIcon,children:I.isApplePay?jsx(Text,{style:C.amount.applePayIcon,children:"\uF8FF"}):jsx(Sd,{sublabel:I.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:C.amount.sheetOptionLabel,children:I.label}),jsx(Text,{style:C.amount.sheetOptionHint,children:I.hint})]})]}),D&&jsx(Le,{size:18,color:x.primary,strokeWidth:2.5})]},I.id)}),jsx(TouchableOpacity$1,{style:C.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!$e.current){$e.current=true;try{let I=await T?.();I&&(le(I.token),Pe(I.sublabel),_e(!1));}finally{$e.current=false;}}},children:jsx(Text,{style:C.amount.addPaymentBtnText,children:"Add Payment Method"})})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:C.amount.sheetHeader,children:[jsx(TouchableOpacity$1,{onPress:()=>{l||we("select");},activeOpacity:.7,style:C.amount.sheetBackBtn,children:jsx(Zi,{size:20,color:x.foreground,strokeWidth:2})}),jsx(Text,{style:C.amount.sheetTitle,children:"Pay With"})]}),l?jsxs(View,{style:C.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:x.primary}),__DEV__?jsx(Text,{style:C.amount.sheetStatusText,children:u||"Loading Stripe Link..."}):null]}):c?jsxs(Fragment,{children:[jsx(View,{style:C.amount.sheetError,children:jsx(Text,{style:C.amount.sheetErrorText,children:c})}),jsx(TouchableOpacity$1,{style:C.form.continueBtn,onPress:()=>{a&&ze&&a(false,W);},children:jsx(Text,{style:C.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:C.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:x.primary}),__DEV__?jsx(Text,{style:C.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})}),jsx(bt,{visible:ar,onClose:()=>{he(false),ot(null);},closeOnBackdropPress:true,enablePanDownToClose:true,showHandle:true,heightPercent:.9,borderTopLeftRadius:v,borderTopRightRadius:M,children:Vt?jsx(Ep,{session:Vt,onBack:()=>ot(null)}):jsxs(View,{style:C.amount.sheetContent,children:[jsx(St,{onPress:()=>he(false),title:"Purchase History"}),b&&jsx(Ap,{active:ar&&!pt&&X.length>0,color:x.primary}),pt?jsx(Wp,{}):me?jsx(View,{style:C.amount.sheetError,children:jsx(Text,{style:C.amount.sheetErrorText,children:me})}):X.length===0?jsx(View,{style:C.amount.sheetLoading,children:jsx(Text,{style:[C.amount.sheetStatusText,{color:x.foregroundMuted}],children:"No purchases yet"})}):jsx(at,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:X.map(I=>{let D=I.transaction_details,q=D?.source_amount?`$${parseFloat(D.source_amount).toFixed(2)}`:"\u2014",Fe=(D?.destination_currency??"").toUpperCase(),ke=D?.destination_amount?`${parseFloat(D.destination_amount).toFixed(2)} ${Fe}`:"",pr=_l(I.created),ce=I.destination_token_metadata,xt=zn(ce?.icon_urls,ce?.icon_url),Ct=zn(ce?.chain?.icon_urls,ce?.chain?.icon_url);return jsxs(TouchableOpacity$1,{style:C.amount.sheetOption,activeOpacity:.7,onPress:()=>ot(I),children:[jsx(as,{currency:Fe||"USD",tokenIconUrl:xt,networkIconUrl:Ct,size:36}),jsxs(View,{style:{flex:1,gap:2,marginLeft:12},children:[jsx(Text,{style:C.amount.sheetOptionLabel,children:q}),ke?jsx(Text,{style:C.amount.sheetOptionHint,children:ke}):null]}),jsxs(View,{style:{flexDirection:"row",alignItems:"center",gap:8},children:[jsxs(View,{style:{alignItems:"flex-end",gap:2},children:[jsx(Bp,{status:I.status,colors:x,fontFamily:k.regular}),pr?jsx(Text,{style:{fontSize:11,color:x.foregroundMuted,fontFamily:k.regular},children:pr}):null]}),jsx(_r,{size:14,color:x.foregroundMuted,strokeWidth:2})]})]},I.id)})})]})})]})}function Ol({initialData:e={},loading:t=false,level:r="L0",onComplete:o,onCancel:n}){let i=Wo(),{colors:s,fonts:a,components:l}=V(),u=l.input.placeholderColor,c=r==="L0"?["name","address"]:["name","dob","address","ssn"],y=c.length,[T,w]=useState(1),[m,g]=useState(e.firstName??""),[h,S]=useState(e.lastName??""),[b,p]=useState(e.dobMonth??""),[d,C]=useState(e.dobDay??""),[x,_]=useState(e.dobYear??""),[k,v]=useState(e.addressLine1??""),[M,W]=useState(e.addressLine2??""),[O,F]=useState(e.city??""),[U,j]=useState(e.state??""),[le,Ye]=useState(e.postalCode??""),[_e,ne]=useState(e.country??"US"),[we,fe]=useState(e.idNumber??""),Pe=useRef(null),$e=useRef(null),ue=useRef(null),J=useRef(null),be=useRef(null),vt=useRef(null),ve=useRef(null),qe=useRef(null),Ne=c[T-1],Ve=()=>{switch(Ne){case "name":return m.trim().length>0&&h.trim().length>0;case "dob":return b.length===2&&d.length===2&&x.length===4;case "address":return k.trim().length>0&&O.trim().length>0&&U.trim().length>0&&le.trim().length>0;case "ssn":return we.trim().length>0;default:return false}},ze=()=>{Ve()&&(T<y?w(Ae=>Ae+1):o({firstName:m,lastName:h,idNumber:we,dobMonth:b,dobDay:d,dobYear:x,addressLine1:k,addressLine2:M,city:O,state:U,postalCode:le,country:_e}));},it=()=>{T>1?w(Ae=>Ae-1):n();},ie={name:{title:"Enter your name",subtitle:"Use your full legal name as it appears on your ID."},dob:{title:"Enter your date of birth",subtitle:"We use this to verify your identity."},address:{title:"Enter your address",subtitle:"Enter the address associated with your ID."},ssn:{title:"Enter your SSN",subtitle:"Your SSN is encrypted and used only for identity verification."}},{subtitle:pe}=ie[Ne],et=[or.stepCounter,{color:s.foregroundMuted},...a.semibold?[{fontFamily:a.semibold}]:[]];return jsx(KeyboardAvoidingView,{style:i.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:i.form.screen,children:[jsxs(View,{style:or.header,children:[jsx(View,{style:or.headerSide,children:!t&&jsx(TouchableOpacity,{style:or.iconButton,onPress:it,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:T>1?"Back":"Cancel",children:jsx(Xs,{size:20,color:l.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:or.headerCenter,children:jsxs(Text,{style:et,children:[T," of ",y]})}),jsx(View,{style:or.headerSide,children:jsx(TouchableOpacity,{style:or.iconButton,onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(st,{size:20,color:l.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:or.progressTrack,children:Array.from({length:y}).map((Ae,Ke)=>jsx(View,{style:[or.progressSegment,{backgroundColor:Ke<T||Ke+1===T?s.primary:s.border}]},Ke))}),jsx(at,{style:i.form.flex,contentContainerStyle:or.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:jsxs(View,{pointerEvents:t?"none":"auto",style:[i.form.flex,t&&{opacity:.5}],children:[jsx(Text,{style:i.form.subtitle,children:pe}),Ne==="name"&&jsxs(Fragment,{children:[jsx(fn,{form:i.form,label:"First name",children:jsx(TextInput,{style:i.form.input,placeholder:"Jane",placeholderTextColor:u,value:m,onChangeText:g,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>Pe.current?.focus()})}),jsx(fn,{form:i.form,label:"Last name",children:jsx(TextInput,{ref:Pe,style:i.form.input,placeholder:"Doe",placeholderTextColor:u,value:h,onChangeText:S,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:ze})})]}),Ne==="dob"&&jsxs(View,{style:or.dobRow,children:[jsxs(View,{style:or.dobCol,children:[jsx(Text,{style:[i.form.fieldLabel,or.dobLabel],children:"Month"}),jsx(TextInput,{style:[i.form.input,or.dobInput],placeholder:"MM",placeholderTextColor:u,value:b,onChangeText:Ae=>{let Ke=Ae.replace(/\D/g,"").slice(0,2);p(Ke),Ke.length===2&&$e.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:or.dobCol,children:[jsx(Text,{style:[i.form.fieldLabel,or.dobLabel],children:"Day"}),jsx(TextInput,{ref:$e,style:[i.form.input,or.dobInput],placeholder:"DD",placeholderTextColor:u,value:d,onChangeText:Ae=>{let Ke=Ae.replace(/\D/g,"").slice(0,2);C(Ke),Ke.length===2&&ue.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:or.dobColWide,children:[jsx(Text,{style:[i.form.fieldLabel,or.dobLabel],children:"Year"}),jsx(TextInput,{ref:ue,style:[i.form.input,or.dobInput],placeholder:"YYYY",placeholderTextColor:u,value:x,onChangeText:Ae=>{let Ke=Ae.replace(/\D/g,"").slice(0,4);_(Ke);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:ze})]})]}),Ne==="address"&&jsxs(Fragment,{children:[jsx(fn,{form:i.form,label:"Street address",children:jsx(TextInput,{style:i.form.input,placeholder:"123 Main St",placeholderTextColor:u,value:k,onChangeText:v,returnKeyType:"next",onSubmitEditing:()=>J.current?.focus()})}),jsx(fn,{form:i.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:J,style:i.form.input,placeholder:"Apt 2",placeholderTextColor:u,value:M,onChangeText:W,returnKeyType:"next",onSubmitEditing:()=>be.current?.focus()})}),jsx(fn,{form:i.form,label:"City",children:jsx(TextInput,{ref:be,style:i.form.input,placeholder:"San Francisco",placeholderTextColor:u,value:O,onChangeText:F,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>vt.current?.focus()})}),jsxs(View,{style:or.row,children:[jsx(View,{style:[i.form.flex,{marginRight:8}],children:jsx(fn,{form:i.form,label:"State",children:jsx(TextInput,{ref:vt,style:i.form.input,placeholder:"CA",placeholderTextColor:u,value:U,onChangeText:Ae=>j(Ae.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>ve.current?.focus()})})}),jsx(View,{style:i.form.flex,children:jsx(fn,{form:i.form,label:"ZIP code",children:jsx(TextInput,{ref:ve,style:i.form.input,placeholder:"94001",placeholderTextColor:u,value:le,onChangeText:Ye,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>qe.current?.focus()})})})]}),jsx(fn,{form:i.form,label:"Country",children:jsx(TextInput,{ref:qe,style:i.form.input,placeholder:"US",placeholderTextColor:u,value:_e,onChangeText:Ae=>ne(Ae.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:ze})})]}),Ne==="ssn"&&jsxs(fn,{form:i.form,label:"Social Security Number",children:[jsx(TextInput,{style:i.form.input,placeholder:"123-45-6789",placeholderTextColor:u,value:we,onChangeText:fe,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:ze}),jsx(Text,{style:[i.form.hint,or.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]})}),jsx(View,{style:i.form.footer,children:t&&T>=y?jsx(View,{style:[i.form.continueBtn,i.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:s.primaryForeground,gradientTo:s.primaryForeground})}):jsx(TouchableOpacity,{style:[i.form.continueBtn,!Ve()&&i.form.continueBtnDisabled],onPress:ze,disabled:!Ve(),children:jsx(Text,{style:[i.form.continueBtnText,!Ve()&&i.form.continueBtnTextDisabled],children:T>=y?"Submit":"Continue"})})})]})})}function fn({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var or=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingTop:16,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:12},progressSegment:{flex:1,height:3,borderRadius:2},scrollContent:{flexGrow:1,paddingBottom:16,paddingTop:4},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 Dd="@unifold/stripe_oauth";async function jp(){try{let e=await Fd.getItem(Dd);return e?JSON.parse(e):null}catch{return null}}async function Vd(e){try{await Fd.setItem(Dd,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function hn(){try{await Fd.removeItem(Dd);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Kg=5,Kn=null,$p={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Fl(e){let t=e?.flowOrder==="amount_first",r=t?"session_params":"email",{configure:o,hasLinkAccount:n,registerLinkUser:i,authorize:s,attachKycInfo:a,presentKycInfoVerification:l,verifyIdentity:u,registerWalletAddress:c,collectPaymentMethod:y,createCryptoPaymentToken:T}=useOnramp(),[w,m]=useState(r),[g,h]=useState(!!e?.externalUserId),[S,b]=useState(false),[p,d]=useState(""),[C,x]=useState(null),[_,k]=useState(e?.email??""),[v,M]=useState(e?.phone??""),[W,O]=useState(""),[F,U]=useState("US"),[j,le]=useState(""),[Ye,_e]=useState(""),ne=useRef(""),we=useRef(""),fe=useRef(""),[Pe,$e]=useState(false),[ue,J]=useState(false),be=useRef(0),vt=useRef(false),ve=useRef(false),qe=useRef(false),Ne=useRef(e?.email??""),Ve=useRef(false),ze=useRef(null),it=useRef(""),ie=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),pe=useRef(null),[et,Ae]=useState(0),[Ke,$t]=useState($p),[Ee,Oe]=useState(e?.defaultWalletAddress??""),[ar,he]=useState(""),[X,Ce]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[pt,It]=useState(e?.defaultSourceAmount??"100"),[me,je]=useState(e?.defaultSourceCurrency??"usd"),[Vt,ot]=useState(e?.defaultDestinationCurrency??"usdc"),[Lt,Bt]=useState(null),[yt,Se]=useState(),[Z,Q]=useState(),[L,I]=useState(false),D=useRef(null),q=useRef(false),Fe=useRef(0),ke=useRef(e?.onComplete),pr=useRef(e?.onError),ce=useRef(e?.onStepChange),xt=useRef(r);useEffect(()=>{ke.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{pr.current=e?.onError;},[e?.onError]),useEffect(()=>{ce.current=e?.onStepChange;},[e?.onStepChange]);let Ct=useRef(r);useEffect(()=>{w!==Ct.current&&(ce.current?.(w,Ct.current),Ct.current=w),xt.current=w;},[w]),useEffect(()=>{g&&w!==r&&h(false);},[g,w,r]);let z=useCallback((R,P,$)=>{let G={code:R,message:P,step:xt.current,stripeErrorCode:$};x(G),d(""),pr.current?.(G);},[]),Xr=useCallback(R=>{let P={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 ke.current?.(P),P},[]),dt=useCallback(()=>x(null),[]),Ga=R=>R.refresh_token??R.refresh?.refresh_token??"",Yi=useCallback((R,P,$,G,de)=>{we.current=P,ne.current=$,e?.externalUserId&&Vd({accessToken:P,refreshToken:$,customerId:R,externalUserId:e.externalUserId,email:de||_,expiresAt:Date.now()+G*1e3});},[e?.externalUserId,_]),Y=useCallback(async()=>{let R=ne.current;if(!R)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let P=await gd(R,fe.current??void 0),$=P.access_token,G=Ga(P)||R;return _e($),Yi(fe.current,$,G,P.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),$}catch(P){return console.error("[tryRefreshAccessToken] refresh failed:",P?.message),await hn(),Kn=null,we.current="",ne.current="",fe.current="",_e(""),le(""),null}},[Yi]),ae=useCallback(async R=>{try{return await R(we.current)}catch(P){let $=P?.message??"";if($.includes("stripe_onramp_forbidden")||$.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let G=await Y();if(!G)throw z("authorization_error","Session expired. Please sign in again."),m("email"),P;return await R(G)}throw P}},[Y,z]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){I(false);return}let P=false;return isPlatformPaySupported().then($=>{P||I($);}),()=>{P=true;}},[e?.merchantIdentifier]),useEffect(()=>(q.current=false,()=>{q.current=true,D.current&&clearTimeout(D.current);}),[]);let qt=useRef(false);useEffect(()=>{if(qt.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),hn(),Kn=null,h(false);return}let R=false;return (async()=>{try{let P=await jp();if(R||!P){R||h(!1);return}if(P.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",P.externalUserId,"current:",e.externalUserId),await hn(),Kn=null,R||h(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",P.customerId);let $=Date.now()>=P.expiresAt,G=P.accessToken,de=P.refreshToken;if($){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let ye=await gd(P.refreshToken,P.customerId);if(R)return;G=ye.access_token,de=ye.refresh_token??ye.refresh?.refresh_token??P.refreshToken,await Vd({accessToken:G,refreshToken:de,customerId:P.customerId,externalUserId:e.externalUserId,email:P.email,expiresAt:Date.now()+(ye.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(ye){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",ye?.message),await hn(),Kn=null,R||h(!1);return}}if(R)return;if(qt.current=!0,le(P.customerId),fe.current=P.customerId,_e(G),we.current=G,ne.current=de,console.log("[useStripeOnramp] restore email from storage:",P.email??"(not stored)"),P.email&&(k(P.email),Ne.current=P.email),Kn===P.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",P.customerId,"\u2014 skipping configure()"),pe.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",P.customerId);let ye=await o({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}},cryptoCustomerId:P.customerId});ye.error?console.error("[useStripeOnramp] restore configureSDK error:",ye.error.message):Kn=P.customerId,pe.current=Promise.resolve(ye);}if(R)return;let _t=()=>new Promise(ye=>{let tt=()=>{Ve.current&&it.current?ye():setTimeout(tt,200);};tt();});try{if(await Promise.race([_t(),new Promise((tt,Wt)=>setTimeout(()=>Wt(new Error("timeout")),1e4))]),R)return;let ye=it.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",ye,"network:",ie.current),await c(ye,ie.current);}catch(ye){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",ye?.message);}if(R)return;try{(await Mn(fe.current,we.current)).verifications.find(Wt=>Wt.name==="kyc_verified")?.status!=="verified"?(console.log("[useStripeOnramp] credentials restored but KYC not verified \u2014 going to kyc"),m("kyc")):(console.log("[useStripeOnramp] credentials restored, KYC verified \u2014 skipping to session_params"),m("session_params"));}catch{console.log("[useStripeOnramp] credentials restored, could not check KYC \u2014 defaulting to kyc"),m("kyc");}}finally{R||h(false);}})(),()=>{R=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress){console.log("[resolveWallet] skipping \u2014 missing:",e?.publishableKey?"":"publishableKey",e?.externalUserId?"":"externalUserId",e?.recipientAddress?"":"recipientAddress");return}if(Pe)return;let R=false;J(true);async function P(){try{console.log("[resolveWallet] fetching deposit address for:",e.externalUserId,e.recipientAddress);let[$,G]=await Promise.all([Pp({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?Op({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Et=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Et?.message),null)):Promise.resolve(null)]);if(R){console.log("[resolveWallet] cancelled after fetch \u2014 discarding stale result");return}let de=e?.destinationChainType??"ethereum",_t=$.data.find(Et=>Et.chain_type===de);if(_t?.address){let Et=_t.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",Et,"recipient:",_t.recipient_address),Oe(Et),it.current=Et,_t.recipient_address&&he(_t.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",de,"in",$.data?.length,"wallets");let ye={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},tt={8453:"base",1:"ethereum",137:"polygon"},Wt=G?.destination_network,xr="none";if(Wt&&ye[Wt])Ce(ye[Wt]),ie.current=ye[Wt],xr=Wt+" (from default_token API)";else if(e?.destinationChainId&&tt[e.destinationChainId]){let Et=tt[e.destinationChainId];ye[Et]&&(Ce(ye[Et]),ie.current=ye[Et]),xr=Et+" (from chain_id "+e.destinationChainId+")";}else ye[de]&&(Ce(ye[de]),ie.current=ye[de],xr=de+" (from chain_type fallback)");G?.destination_currency&&ot(G.destination_currency.toLowerCase());let At=G?.destination_token_metadata,lr=zn(At?.icon_urls,At?.icon_url),Vr=zn(At?.chain?.icon_urls,At?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",lr,"network:",Vr),lr&&Se(lr),Vr&&Q(Vr),console.log("[resolveWallet] \u2705 setting walletReady = true"),$e(!0),Ve.current=!0;}catch($){if(R)return;console.error("[resolveWallet] Failed to resolve wallet:",$?.message),$e(true),Ve.current=true;}finally{R||J(false);}}return ze.current=P(),()=>{R=true;}},[e?.publishableKey,e?.externalUserId,et]);let Tr=useCallback(async()=>{if(pe.current)return pe.current;let R=o({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(P=>(P.error&&(console.error("[useStripeOnramp] configureSDK error:",P.error.message,P.error.code),pe.current=null),P)).catch(P=>{throw console.error("[useStripeOnramp] configureSDK threw:",P?.message??P),pe.current=null,P});return pe.current=R,R},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||Tr();},[]);let an=useCallback(async R=>{if(!vt.current){vt.current=true,b(true),dt(),d("Creating auth intent...");try{let P=await hd(R);d("Waiting for authorization...");let $=await s(P);if($?.error){console.log("[proceedToAuthorize] authorize error:",$.error.message),z("authorization_error","Something went wrong during authorization. Please try again."),m("email");return}if($?.status==="Denied"){z("authorization_error","Authorization denied by user."),m("email");return}if($?.status!=="Consented"||!$.customerId){z("authorization_error","Authorization was canceled."),m("email");return}d("Exchanging tokens...");let G=$.customerId,de=await xp(P,G),_t=de.access_token,ye=Ga(de);console.log("[useStripeOnramp] customerId:",G),console.log("[useStripeOnramp] accessToken acquired, length:",_t.length),k(R),Ne.current=R,le(G),fe.current=G,Kn=G,_e(_t),Yi(G,_t,ye,de.expires_in??3600,R),d("Checking verification status...");try{let tt=await Mn(G,_t),Wt=tt.verifications.find(Vr=>Vr.name==="kyc_verified"),xr=Wt?.status==="verified",At=Wt?.status==="rejected",lr=tt.provided_fields.includes("first_name");if(d(""),At&&!lr)z("kyc_error","KYC was previously rejected. Please submit with correct info."),m("kyc");else if(!xr)m("kyc");else {ze.current&&(d("Resolving wallet..."),await ze.current,d(""));let Vr=it.current;if(Vr)try{let Et=Vr.toLowerCase(),Gs=ie.current;console.log("[proceedToAuthorize] registering wallet:",Et,"network:",Gs);let gi=await c(Et,Gs);gi?.error?(console.warn("[proceedToAuthorize] wallet registration error:",gi.error.message),z("wallet_error",gi.error.message,gi.error.code),m("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),m("kyc_offer"));}catch(Et){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",Et?.message),m("wallet");}else console.log("[proceedToAuthorize] no resolved deposit address available, going to wallet step"),m("wallet");}}catch(tt){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",tt?.message),d(""),m("kyc");}}catch(P){z("authorization_error",P?.message??String(P)),m("email");}finally{vt.current=false,b(false);}}},[s,dt,z,Yi,c,X]),Bn=useCallback(async()=>{if(Keyboard.dismiss(),!_){z("validation_error","Please enter an email address.");return}b(true),dt(),d("");try{d("Configuring...");let R=await Tr();if(R.error){z("configuration_error",R.error.message,R.error.code);return}d("Checking Link account...");let P=await n(_);if(P.error){z("authorization_error",P.error.message,P.error.code);return}console.log("[checkEmail] link.hasLinkAccount:",P.hasLinkAccount),P.hasLinkAccount?await an(_):(d(""),m("disclaimer"));}catch(R){z("unknown_error",R?.message??String(R));}finally{b(false);}},[dt,Tr,_,z,n,an]),Wn=useCallback(async()=>{if(!qe.current){if(!v){z("validation_error","Please enter your phone number.");return}qe.current=true,b(true),dt(),d("");try{d("Creating Link account...");let R=await i({email:_,phone:v,fullName:W||_,country:F||"US"});if(R.error){z("registration_error",R.error.message,R.error.code);return}await an(_);}catch(R){z("registration_error",R?.message??String(R));}finally{qe.current=false,b(false);}}},[dt,F,_,z,W,v,i,an]);useEffect(()=>{if(w!=="email"||!e?.email||g)return;let R=++be.current,P=false,$=()=>P||be.current!==R;return e?.phone?(async()=>{b(true),dt();try{d("Configuring...");let G=await Tr();if($())return;if(G.error){z("configuration_error",G.error.message,G.error.code);return}d("Checking Link account...");let de=await n(e.email);if($())return;if(de.error){z("authorization_error",de.error.message,de.error.code);return}if(de.hasLinkAccount){if($())return;await an(e.email);}else {if($())return;d(""),m("disclaimer");}}catch(G){$()||z("unknown_error",G?.message??String(G));}finally{b(false);}})():(async()=>{b(true),dt();try{d("Configuring...");let G=await Tr();if($())return;if(G.error){z("configuration_error",G.error.message,G.error.code);return}d("Checking Link account...");let de=await n(e.email);if($())return;if(de.error){z("authorization_error",de.error.message,de.error.code);return}if(de.hasLinkAccount){if($())return;await an(e.email);}else {if($())return;d(""),m("disclaimer");}}catch(G){$()||z("unknown_error",G?.message??String(G));}finally{b(false);}})(),()=>{P=true;}},[w,e?.email,e?.phone,g]);let Ja=useCallback(async()=>{ze.current&&(d("Resolving wallet..."),await ze.current);let R=it.current;if(R)try{d("Registering wallet...");let P=R.toLowerCase(),$=ie.current;console.log("[resolveAndRegisterWallet] registering wallet:",P,"network:",$),await c(P,$);}catch(P){console.warn("[resolveAndRegisterWallet] wallet registration failed (non-fatal):",P?.message);}else console.warn("[resolveAndRegisterWallet] no resolved deposit address \u2014 skipping registration");},[c]),sh=useCallback(async(R,P)=>{b(true),dt(),d(""),$t(de=>({...de,...R}));let $=P??"kyc_offer",G=P?"kyc_l1":"kyc";try{let de=R.dobDay&&R.dobMonth&&R.dobYear,_t=R.firstName&&R.lastName,ye={};_t&&(ye.firstName=R.firstName,ye.lastName=R.lastName),R.addressLine1&&(ye.address={line1:R.addressLine1,line2:R.addressLine2||void 0,city:R.city,state:R.state,postalCode:R.postalCode,country:R.country}),R.idNumber&&(ye.idNumber=R.idNumber),de&&(ye.dateOfBirth={day:parseInt(R.dobDay,10),month:parseInt(R.dobMonth,10),year:parseInt(R.dobYear,10)}),console.log("[attachKyc] sending kycInfo:",JSON.stringify(ye,null,2));let tt=await a(ye);if(console.log("[attachKyc] attachKycInfo result:",JSON.stringify(tt,null,2)),tt?.error?.message&&(/no active link consumer/i.test(tt.error.message)||/not be verified/i.test(tt.error.message))){if(console.log("[attachKyc] Link session invalid \u2014 re-establishing session"),d("Verifying identity..."),!await Ys()){z("kyc_error","Please verify your identity to continue."),m(G);return}tt=await a(ye),console.log("[attachKyc] retry attachKycInfo result:",JSON.stringify(tt,null,2));}if(tt?.error){if(tt.error.stripeErrorCode==="consumer_person_already_verified"){console.log("[attachKyc] already verified, resolving wallet before",$),await Ja(),d(""),m($);return}z("kyc_error",tt.error.message,tt.error.stripeErrorCode??tt.error.code),m(G);return}if(!(tt&&Object.keys(tt).length>0&&!tt.error)){let lr=P?"l1":"l0";if(console.log(`[attachKyc] success (no verification needed), waiting for ${lr} verified...`),d("Verifying identity..."),!fe.current||!we.current){console.warn(`[attachKyc] \u274C cannot poll ${lr} \u2014 missing customerIdRef or accessTokenRef`),z("kyc_error","Unable to verify identity. Please try again."),m(G);return}let Vr=fe.current,Et=we.current,Gs=10,gi=!1;for(let Hc=0;Hc<Gs;Hc++){try{let rl=(await Mn(Vr,Et)).kyc_tiers?.find(fh=>fh.tier===lr);if(console.log(`[attachKyc] ${lr} poll #${Hc+1}: verification_status=${rl?.verification_status}`),rl?.verification_status==="verified"){console.log(`[attachKyc] \u2705 ${lr} verified!`),gi=!0;break}if(rl?.verification_status==="rejected"){console.warn(`[attachKyc] \u274C ${lr} rejected:`,rl?.verification_errors),z("kyc_error","KYC verification was rejected. Please try again."),m(G);return}}catch(tl){console.warn(`[attachKyc] ${lr} poll error:`,tl?.message);}await new Promise(tl=>setTimeout(tl,2e3));}if(!gi){console.warn(`[attachKyc] \u274C ${lr} verification timed out after`,Gs,"attempts"),z("kyc_error","Identity verification is taking longer than expected. Please try again."),m(G);return}await Ja(),d(""),m($);return}console.log("[attachKyc] calling presentKycInfoVerification..."),d("Please review your KYC information...");let At=await l(null);if(console.log("[attachKyc] presentKycInfoVerification result:",JSON.stringify(At,null,2)),At?.error){z("kyc_error",At.error.message,At.error.stripeErrorCode??At.error.code),m(G);return}if(At?.status==="UpdateAddress"){z("kyc_error","Please update your address and resubmit."),m(G);return}await Ja(),d(""),console.log("[attachKyc] success, navigating to:",$),m($);}catch(de){z("kyc_error",de?.message??String(de)),m(G);}finally{b(false);}},[a,dt,z,l,Ja]),Ys=useCallback(async()=>{let R=Ne.current||e?.email;if(!R)return console.warn("[reestablishLinkSession] no email available \u2014 emailRef:",JSON.stringify(Ne.current),"config.email:",e?.email),false;try{console.log("[reestablishLinkSession] re-establishing Link session for:",R);let P=await hd(R),$=await s(P);return $?.status==="Consented"&&$.customerId?(console.log("[reestablishLinkSession] success, customerId:",$.customerId),fe.current=$.customerId,le($.customerId),!0):(console.warn("[reestablishLinkSession] authorize did not consent:",$?.status),!1)}catch(P){return console.warn("[reestablishLinkSession] failed:",P?.message),false}},[s,e?.email]),Gu=useCallback(async()=>{if(!ve.current){ve.current=true,b(true),dt(),d("Launching identity verification...");try{let R=await u();if(R?.error?.message&&(/no active link consumer/i.test(R.error.message)||/not be verified/i.test(R.error.message))){if(console.log("[verifyIdentity] Link session invalid \u2014 re-establishing session"),d("Verifying identity..."),!await Ys()){z("identity_error","Please verify your identity to continue.");return}R=await u();}if(R?.error){let $=R.error.message??"";if(/cancel/i.test($)){console.log("[verifyIdentity] cancelled by user, returning silently"),d("");return}z("identity_error",$,R.error.code);return}d(""),Za.current?(Za.current=!1,m("session_params")):m("wallet");}catch(R){z("identity_error",R?.message??String(R));}finally{ve.current=false,b(false);}}},[dt,z,Ys,u]),Za=useRef(false);useEffect(()=>{w==="identity"&&!S&&Gu();},[w]);let Ju=useCallback(async()=>{if(console.log("[registerWallet] called. walletAddress:",Ee,"walletNetwork:",X),!Ee){z("validation_error","Please enter a wallet address.");return}b(true),dt(),d("");try{let R=Ee.toLowerCase();console.log("[registerWallet] registering wallet:",R,"network:",X);let P=await c(R,X);if(console.log("[registerWallet] result:",JSON.stringify(P,null,2)),P?.error){console.warn("[registerWallet] error:",P.error.message),z("wallet_error",P.error.message,P.error.code);return}console.log("[registerWallet] wallet registered successfully \u2192 kyc_offer"),d(""),m("kyc_offer");}catch(R){console.error("[registerWallet] exception:",R?.message??String(R)),z("wallet_error",R?.message??String(R));}finally{b(false);}},[dt,z,Ee,X,c]);useEffect(()=>{console.log("[auto-register] step:",w,"walletReady:",Pe,"walletAddress:",Ee||"(empty)"),w==="wallet"&&Pe&&Ee&&(console.log("[auto-register] triggering registerWallet() with address:",Ee),Ju());},[w,Pe,Ee]);let Xa=useCallback(R=>{q.current=false,Fe.current=0;let P=0,$=async()=>{P+=1;let G=we.current;try{let de=await Ip(R,G);if(console.log(`[pollSessionStatus] poll #${P} session=${R} status="${de.status}"`),q.current)return;Fe.current=0,de.status==="fulfillment_complete"?(Bt(de),m("success")):D.current=setTimeout($,3e3);}catch(de){if(q.current)return;let _t=de?.message??"";if((_t.includes("stripe_onramp_forbidden")||_t.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await Y()&&!q.current)){D.current=setTimeout($,1e3);return}if(Fe.current+=1,console.error(`[pollSessionStatus] poll #${P} error:`,_t),Fe.current>=Kg){z("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}D.current=setTimeout($,5e3);}};D.current=setTimeout($,3e3);},[z,Y]),ah=useCallback(()=>{if(xt.current==="processing"&&Lt?.id){if(!we.current){z("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}dt(),Fe.current=0,D.current&&(clearTimeout(D.current),D.current=null),Xa(Lt.id);}},[dt,z,Xa,Lt?.id]),el=useCallback(async R=>{b(true),dt(),d("");try{d("Confirming purchase...");let P=await ae($=>Rp(R,$));console.log("[finalizeOnrampSession] confirmed session:",P.id,"status:",P.status),Bt(P),m("processing"),d(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",P.id),Xa(P.id);}finally{b(false);}},[dt,Xa,ae]),zc=useRef(false),lh=useCallback(async()=>{if(!(!Lt||zc.current)){zc.current=true;try{b(!0),dt(),d("Refreshing quote...");let R=await ae(P=>yd(Lt.id,P));Bt(R),await el(R.id);}catch(R){console.log("[confirmCheckout] error:",R?.message),z("session_error","Something went wrong. Please try again."),m("quote");}finally{b(false),zc.current=false;}}},[dt,z,el,Lt,ae]),ch=useCallback(async(R=false,P,$)=>{let G=P??pt;if(console.log("[collectPaymentMethod] called:",{useApplePay:R,amt:G,amountOverride:P,sourceAmount:pt,hasSavedToken:!!$}),!G||isNaN(Number(G))||Number(G)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),z("validation_error","Please enter a valid amount.");return}P&&It(P),b(true),dt(),d("");try{let de=await Tr();if(de.error){z("configuration_error",de.error.message,de.error.code);return}let _t;if($)console.log("[collectPaymentMethod] using saved payment token"),_t=$;else if(R){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),z("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),m("session_params");return}d("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let Wt={applePay:{merchantCountryCode:"US",currencyCode:me.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${Vt.toUpperCase()} purchase + fees`,amount:G}]}},xr=await y("PlatformPay",Wt);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!xr?.error),xr?.error){let lr=xr.error.message??"",Vr=xr.error.code??"",Et=/cancel/i.test(lr)||/cancel/i.test(Vr);console.log("[collectPaymentMethod] pmResult error:",xr.error,"isCancellation:",Et),Et||(z("payment_error",lr,Vr),m("session_params"));return}if(!xr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}d("Creating payment token...");let At=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!At?.error),At?.error){z("payment_error",At.error.message,At.error.code),m("session_params");return}_t=At.cryptoPaymentToken;}else {d("Select a payment method...");let Wt=await y("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Wt?.error),Wt?.error){let lr=Wt.error.message??"",Vr=Wt.error.code??"",Et=/cancel/i.test(lr)||/cancel/i.test(Vr);console.log("[collectPaymentMethod] pmResult error:",Wt.error,"isCancellation:",Et),Et||(z("payment_error",lr,Vr),m("session_params"));return}if(!Wt?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let xr=Wt.displayData;console.log("[collectPaymentMethod] displayData:",{type:xr.type,label:xr.label,sublabel:xr.sublabel,hasIcon:!!xr.icon}),d("Creating payment token...");let At=await T();if(console.log("[collectPaymentMethod] tokenResult ok:",!At?.error),At?.error){z("payment_error",At.error.message,At.error.code),m("session_params");return}_t=At.cryptoPaymentToken;}d("Creating onramp session...");let ye=it.current||Ee;if(console.log("[collectPaymentMethod] creating onramp session, sessionWalletAddress:",ye),!ye){z("wallet_error","No wallet address available. Please go back and enter a wallet address.");return}let tt=await ae(Wt=>_p({cryptoCustomerId:fe.current,paymentToken:_t,sourceAmount:Number(G),sourceCurrency:me,destinationCurrency:Vt,walletAddress:ye,destinationNetwork:X},Wt));console.log("[collectPaymentMethod] session created:",tt?.id,"useApplePay:",R),Bt(tt),d(""),R?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await el(tt.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):m("quote");}catch(de){console.log("[collectPaymentMethod] error caught:",de?.message),z("session_error","Something went wrong. Please try again."),m("session_params");}finally{b(false),d("");}},[dt,Tr,y,T,Vt,z,el,It,pt,me,Ee,X,ae,e?.merchantIdentifier]),dh=useCallback(async()=>{b(true),dt(),d("Select a payment method...");try{let R=await Tr();if(R.error)return z("configuration_error",R.error.message,R.error.code),null;let P=await y("Card");if(console.log("[addPaymentMethod] Card result ok:",!P?.error),P?.error?.message&&(/no active link consumer/i.test(P.error.message)||/not be verified/i.test(P.error.message))){if(console.log("[addPaymentMethod] Link session invalid \u2014 re-establishing session"),!await Ys())return z("authorization_error","Please verify your identity to add a payment method."),null;P=await y("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!P?.error);}if(P?.error){let _t=P.error.message??"",ye=P.error.code??"",tt=/cancel/i.test(_t)||/cancel/i.test(ye);return console.log("[addPaymentMethod] pmResult error:",P.error,"isCancellation:",tt),tt||z("payment_error",_t,ye),null}if(!P?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let G=P.displayData;console.log("[addPaymentMethod] displayData:",{type:G.type,label:G.label,sublabel:G.sublabel,hasIcon:!!G.icon}),d("Saving payment method...");let de=await T();return console.log("[addPaymentMethod] tokenResult ok:",!de?.error),de?.error?(z("payment_error",de.error.message,de.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:de.cryptoPaymentToken,sublabel:G.sublabel??""})}catch(R){return console.log("[addPaymentMethod] error:",R?.message),z("session_error",R?.message??String(R)),null}finally{b(false),d("");}},[dt,Tr,y,T,z,Ys]),uh=useCallback(async()=>{if(Lt){b(true),dt(),d("");try{let R=await ae(P=>yd(Lt.id,P));Bt(R);}catch(R){console.log("[refreshQuote] error:",R?.message),z("session_error","Something went wrong. Please try again.");}finally{b(false);}}},[dt,z,Lt,ae]),Uc=useCallback(()=>{q.current=true,Fe.current=0,D.current&&(clearTimeout(D.current),D.current=null),m(r),b(false),d(""),x(null),k(e?.email??""),Ne.current=e?.email??"",M(e?.phone??""),O(""),U("US"),le(""),fe.current="",_e(""),we.current="",ne.current="",$e(false),J(false),ze.current=null,Ae(R=>R+1),$t($p),Oe(""),it.current="",Ve.current=false,Ce(Onramp.CryptoNetwork.ethereum),It(e?.defaultSourceAmount??"100"),je(e?.defaultSourceCurrency??"usd"),ot(e?.defaultDestinationCurrency??"usdc"),he(""),Se(void 0),Q(void 0),Bt(null),be.current+=1,vt.current=false,ve.current=false,qe.current=false;},[e,r]),ph=useCallback(()=>{Za.current=true,m("kyc_offer");},[]),mh=useCallback(async()=>{await hn(),Kn=null,Uc();},[Uc]);return {step:w,restoring:g,loading:S,status:p,error:C,email:_,phone:v,fullName:W,country:F,customerId:j,accessToken:Ye,session:Lt,kycData:Ke,walletAddress:Ee,resolvedRecipientAddress:ar,walletNetwork:X,sourceAmount:pt,sourceCurrency:me,destinationCurrency:Vt,tokenIconUrl:yt,networkIconUrl:Z,applePaySupported:L,walletReady:Pe,walletLoading:ue,setStep:m,setStatus:d,setEmail:k,setPhone:M,setFullName:O,setCountry:U,setWalletAddress:Oe,setWalletNetwork:Ce,setSourceAmount:It,setSourceCurrency:je,setDestinationCurrency:ot,checkEmail:Bn,register:Wn,attachKyc:sh,verifyIdentity:Gu,requestKYCUpgrade:ph,kycUpgradeMode:Za,logout:mh,registerWallet:Ju,collectPaymentMethod:ch,addPaymentMethod:dh,refreshQuote:uh,confirmCheckout:lh,reset:Uc,clearError:dt,emitComplete:Xr,resumeFulfillmentPolling:ah,amountFirst:t}}function qp({initialData:e={},loading:t=false,onComplete:r,onCancel:o,onClose:n}){let i=Wo(),{colors:s,fonts:a,components:l}=V(),u=l.input.placeholderColor,[c,y]=useState(e.dobMonth??""),[T,w]=useState(e.dobDay??""),[m,g]=useState(e.dobYear??""),[h,S]=useState(e.idNumber??""),b=useRef(null),p=useRef(null),d=useRef(null),C=c.length===2&&T.length===2&&m.length===4&&h.trim().length>0,x=()=>{console.log("[KYCL1Screen] handleSubmit \u2014 canSubmit:",C,"dobMonth:",c,"dobDay:",T,"dobYear:",m,"idNumber:",h?"set":"empty"),C&&r({dobMonth:c,dobDay:T,dobYear:m,idNumber:h});};return jsx(KeyboardAvoidingView,{style:i.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:i.form.screen,children:[jsx(St,{onPress:t?n??o:o,title:"Increase Your Limits",variant:t?"close":"back"}),jsx(at,{style:i.form.flex,contentContainerStyle:Uo.scrollContent,keyboardShouldPersistTaps:"handled",children:jsxs(View,{pointerEvents:t?"none":"auto",style:{opacity:t?.5:1},children:[jsx(Text,{style:i.form.title,children:"Date of birth & SSN"}),jsx(Text,{style:i.form.subtitle,children:"This information is used to verify your identity and increase your transaction limits."}),jsxs(View,{style:Uo.section,children:[jsx(Text,{style:[i.form.fieldLabel,{marginBottom:8}],children:"Date of birth"}),jsxs(View,{style:Uo.dobRow,children:[jsx(View,{style:Uo.dobCol,children:jsx(TextInput,{style:[i.form.input,Uo.dobInput],placeholder:"MM",placeholderTextColor:u,value:c,onChangeText:_=>{let k=_.replace(/\D/g,"").slice(0,2);y(k),k.length===2&&b.current?.focus();},keyboardType:"number-pad",maxLength:2,editable:!t})}),jsx(View,{style:Uo.dobCol,children:jsx(TextInput,{ref:b,style:[i.form.input,Uo.dobInput],placeholder:"DD",placeholderTextColor:u,value:T,onChangeText:_=>{let k=_.replace(/\D/g,"").slice(0,2);w(k),k.length===2&&p.current?.focus();},keyboardType:"number-pad",maxLength:2,editable:!t})}),jsx(View,{style:Uo.dobColWide,children:jsx(TextInput,{ref:p,style:[i.form.input,Uo.dobInput],placeholder:"YYYY",placeholderTextColor:u,value:m,onChangeText:_=>{let k=_.replace(/\D/g,"").slice(0,4);g(k),k.length===4&&d.current?.focus();},keyboardType:"number-pad",maxLength:4,editable:!t})})]})]}),jsxs(View,{style:Uo.section,children:[jsx(Text,{style:[i.form.fieldLabel,{marginBottom:8}],children:"Social Security Number"}),jsx(TextInput,{ref:d,style:i.form.input,placeholder:"123-45-6789",placeholderTextColor:u,value:h,onChangeText:S,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:x,editable:!t}),jsx(Text,{style:[i.form.hint,{marginTop:10,lineHeight:18}],children:"Your SSN is transmitted securely and never stored on this device."})]})]})}),jsx(View,{style:i.form.footer,children:t?jsx(View,{style:[i.form.continueBtn,i.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:s.primaryForeground,gradientTo:s.primaryForeground})}):jsx(TouchableOpacity,{style:[i.form.continueBtn,!C&&i.form.continueBtnDisabled],onPress:x,disabled:!C,children:jsx(Text,{style:[i.form.continueBtnText,!C&&i.form.continueBtnTextDisabled],children:"Submit"})})})]})})}var Uo=StyleSheet.create({scrollContent:{flexGrow:1,paddingBottom:16,paddingTop:16},section:{marginTop:20},dobRow:{flexDirection:"row",gap:10},dobCol:{flex:1},dobColWide:{flex:1.5},dobInput:{textAlign:"center"}});function Bd({borderRadius:e,backgroundColor:t,borderColor:r,borderWidth:o}){let n=useRef(new Animated.Value(.3)).current;return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(n,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(n,{toValue:.3,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[n]),jsxs(Animated.View,{style:[Ge.card,{backgroundColor:t,borderRadius:e,borderColor:r,borderWidth:o,opacity:n}],children:[jsx(View,{style:Ge.skeletonLine}),jsx(View,{style:[Ge.skeletonLine,{width:"60%"}]})]})}function Kp({onRefresh:e,colors:t,fonts:r}){let[o,n]=useState(10),i=useRef(null);useEffect(()=>(i.current=setInterval(()=>{n(a=>a<=1?(i.current&&clearInterval(i.current),0):a-1);},1e3),()=>{i.current&&clearInterval(i.current);}),[]);let s=useCallback(()=>{o>0||(e(),n(10),i.current=setInterval(()=>{n(a=>a<=1?(i.current&&clearInterval(i.current),0):a-1);},1e3));},[o,e]);return jsxs(TouchableOpacity,{onPress:s,disabled:o>0,style:[Ge.refreshBtn,{opacity:o>0?.4:1}],activeOpacity:.7,children:[jsx(Xi,{size:14,color:t.foregroundMuted,strokeWidth:2}),o>0?jsxs(Text,{style:[Ge.refreshText,{color:t.foregroundMuted,fontFamily:r.regular}],children:[o,"s"]}):null]})}function Jp({onSelectL1:e,onSelectL2:t,onSkip:r,onClose:o,onRefresh:n,loading:i=false,loadingTiers:s=false,error:a,l0Status:l="not_started",l1Status:u="not_started",l2Status:c="not_started",l1Completed:y=false,l2Completed:T=false,currentLimit:w}){let m=Wo(),{colors:g,fonts:h,components:S}=V(),b=[Ge.card,{backgroundColor:S.card.backgroundColor,borderRadius:S.card.borderRadius??12,borderWidth:S.card.borderWidth,borderColor:S.card.borderColor}],p=[...b,{opacity:.5}],d=l==="verified",C=u==="verified",x=c==="verified",_=u==="pending"||d&&y&&!C,k=c==="pending"||d&&T&&!x,v=x,M=d&&!C,W=d&&!x,O=!v,F=U=>`$${U.toLocaleString()}`;return jsxs(View,{style:m.form.screen,children:[jsx(St,{onPress:o,title:"Increase Your Limits"}),jsxs(View,{style:Ge.content,children:[w!==void 0?jsxs(View,{style:[Ge.limitBadge,{backgroundColor:S.card.backgroundColor,borderColor:S.card.borderColor,borderWidth:S.card.borderWidth,borderRadius:S.card.borderRadius??12}],children:[jsx(Text,{style:[Ge.limitLabel,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Current transaction limit"}),jsxs(Text,{style:[Ge.limitValue,{color:g.foreground,fontFamily:h.semibold}],children:[F(w)," USD"]})]}):jsx(Bd,{borderRadius:S.card.borderRadius??12,backgroundColor:S.card.backgroundColor,borderColor:S.card.borderColor,borderWidth:S.card.borderWidth}),jsx(Text,{style:[Ge.subtitle,{color:g.foregroundMuted,fontFamily:h.regular}],children:s?"Checking your verification status...":v?"All verification levels have been completed. Your limits are at the maximum available.":"Complete additional verification to increase your transaction limits."}),s?jsxs(Fragment,{children:[jsx(Bd,{borderRadius:S.card.borderRadius??12,backgroundColor:S.card.backgroundColor,borderColor:S.card.borderColor,borderWidth:S.card.borderWidth}),jsx(Bd,{borderRadius:S.card.borderRadius??12,backgroundColor:S.card.backgroundColor,borderColor:S.card.borderColor,borderWidth:S.card.borderWidth})]}):jsxs(Fragment,{children:[M&&(C?jsxs(View,{style:p,children:[jsxs(View,{style:Ge.completedRow,children:[jsx(jr,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold,flex:1}],children:"Date of Birth & SSN"}),jsx(Le,{size:18,color:g.primary,strokeWidth:2.5})]}),jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular,marginLeft:28}],children:"Completed"})]}):_?jsxs(View,{style:b,children:[jsxs(View,{style:Ge.pendingHeader,children:[jsx(jr,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold,flex:1}],children:"Date of Birth & SSN"}),n?jsx(Kp,{onRefresh:n,colors:g,fonts:h}):null]}),jsxs(View,{style:[Ge.pendingFooter,{marginLeft:28}],children:[jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Verification in progress..."}),jsx(nt,{size:18,strokeWidth:2,gradientFrom:g.primary,gradientTo:g.primary})]})]}):jsxs(TouchableOpacity,{style:[b,Ge.cardRow],onPress:e,activeOpacity:.7,children:[jsx(jr,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsxs(View,{style:Ge.cardContent,children:[jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold}],children:"Provide Date of Birth & SSN"}),jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Increases your per-transaction and weekly limits."})]}),jsx(_r,{size:18,color:g.foregroundMuted,strokeWidth:2})]})),W&&(x?jsxs(View,{style:p,children:[jsxs(View,{style:Ge.completedRow,children:[jsx(sl,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold,flex:1}],children:"Photo ID & Selfie"}),jsx(Le,{size:18,color:g.primary,strokeWidth:2.5})]}),jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular,marginLeft:28}],children:"Completed"})]}):k?jsxs(View,{style:b,children:[jsxs(View,{style:Ge.pendingHeader,children:[jsx(sl,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold,flex:1}],children:"Photo ID & Selfie"}),n?jsx(Kp,{onRefresh:n,colors:g,fonts:h}):null]}),jsxs(View,{style:[Ge.pendingFooter,{marginLeft:28}],children:[jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Verification in progress..."}),jsx(nt,{size:18,strokeWidth:2,gradientFrom:g.primary,gradientTo:g.primary})]})]}):jsxs(TouchableOpacity,{style:[b,Ge.cardRow],onPress:t,activeOpacity:.7,children:[jsx(sl,{size:20,color:g.foregroundMuted,strokeWidth:1.8}),jsxs(View,{style:Ge.cardContent,children:[jsx(Text,{style:[Ge.cardTitle,{color:g.foreground,fontFamily:h.semibold}],children:"Provide Photo ID & Selfie"}),jsx(Text,{style:[Ge.cardBody,{color:g.foregroundMuted,fontFamily:h.regular}],children:"Unlocks the highest transaction limits available."})]}),jsx(_r,{size:18,color:g.foregroundMuted,strokeWidth:2})]}))]})]}),jsxs(View,{style:Ge.footer,children:[a?jsx(Text,{style:[m.form.subtitle,{marginBottom:12,textAlign:"center",color:"red"}],children:a}):null,i?jsxs(View,{style:Ge.loaderRow,children:[jsx(nt,{size:24,strokeWidth:2,gradientFrom:g.primary,gradientTo:g.primary}),jsx(Text,{style:[m.form.ghostBtnText,{marginLeft:8}],children:"Verifying..."})]}):O?jsx(TouchableOpacity,{style:m.form.ghostBtn,onPress:r,activeOpacity:.7,children:jsx(Text,{style:m.form.ghostBtnText,children:"Skip for now"})}):jsx(TouchableOpacity,{style:m.form.continueBtn,onPress:r,activeOpacity:.7,children:jsx(Text,{style:m.form.continueBtnText,children:"Done"})})]})]})}var Ge=StyleSheet.create({content:{flex:1,paddingTop:24,gap:16},limitBadge:{alignItems:"center",paddingVertical:24,paddingHorizontal:20,gap:4},limitLabel:{fontSize:13},limitValue:{fontSize:20,paddingTop:8},subtitle:{fontSize:15,lineHeight:22,textAlign:"center",paddingHorizontal:16,paddingVertical:24},card:{padding:20,gap:6},cardRow:{flexDirection:"row",alignItems:"center",gap:16},cardContent:{flex:1,gap:6},cardTitle:{fontSize:16},cardBody:{fontSize:14,lineHeight:20},completedRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:8},skeletonLine:{height:14,borderRadius:7,backgroundColor:"rgba(128, 128, 128, 0.15)",width:"80%",marginBottom:6},pendingHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:4,gap:8},pendingFooter:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},refreshBtn:{flexDirection:"row",alignItems:"center",gap:4,paddingVertical:2,paddingHorizontal:4},refreshText:{fontSize:12},footer:{paddingTop:12,gap:4},loaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:12}});var Bl={linkOnrampTerms:"https://link.com/terms/crypto-onramp",bridgeTerms:"https://www.bridge.xyz/legal/us-terms/bridge-building-inc",linkPrivacy:"https://link.com/privacy",bridgePrivacy:"https://www.bridge.xyz/legal/us-privacy-policy/bridge-building-inc"};function Xp({styles:e,merchantDisplayName:t="This app",onContinue:r,onClose:o}){let{colors:n,fonts:i,components:s}=V(),a=[vo.link,{color:n.primary,fontFamily:i.medium}],l=s.card.borderRadius??12;return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:o,title:"Verify Your Identity"}),jsx(View,{style:vo.logoRow,children:jsx(ip,{height:20,color:n.foreground})}),jsxs(ScrollView,{style:vo.scroll,contentContainerStyle:vo.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:[vo.card,{backgroundColor:s.card.backgroundColor,borderRadius:l,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsx(Text,{style:[vo.sectionTitle,{color:n.foreground,fontFamily:i.semibold}],children:"Description"}),jsxs(Text,{style:[vo.body,{color:n.foregroundMuted,fontFamily:i.regular}],children:["You must verify your identity using Link. ",t," will create or access your Link account on your behalf."]})]}),jsxs(View,{style:[vo.card,{backgroundColor:s.card.backgroundColor,borderRadius:l,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsx(Text,{style:[vo.sectionTitle,{color:n.foreground,fontFamily:i.semibold}],children:"Terms"}),jsxs(Text,{style:[vo.body,{color:n.foregroundMuted,fontFamily:i.regular}],children:["Your data will be encrypted and processed by our partner, Stripe. Funds transfer services are provided by Stripe Payments Company. Cryptocurrency conversion services are provided by Bridge. By continuing you agree to the"," ",jsx(Text,{style:a,onPress:()=>Linking.openURL(Bl.linkOnrampTerms),children:"Link Onramp Terms"}),","," ",jsx(Text,{style:a,onPress:()=>Linking.openURL(Bl.bridgeTerms),children:"Bridge Terms"})," ","and you acknowledge receipt of the"," ",jsx(Text,{style:a,onPress:()=>Linking.openURL(Bl.linkPrivacy),children:"Link US Consumer Privacy Notice"})," ","and the"," ",jsx(Text,{style:a,onPress:()=>Linking.openURL(Bl.bridgePrivacy),children:"Bridge Privacy Notice"}),"."]})]})]}),jsxs(View,{style:vo.footer,children:[jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:r,activeOpacity:.7,children:jsx(Text,{style:e.form.continueBtnText,children:"Continue"})}),jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:o,activeOpacity:.7,children:jsx(Text,{style:e.form.ghostBtnText,children:"Cancel"})})]})]})}var vo=StyleSheet.create({logoRow:{paddingVertical:24,alignItems:"center"},scroll:{flex:1},scrollContent:{paddingTop:16,paddingBottom:16,gap:12},card:{padding:20,gap:10},sectionTitle:{fontSize:15},body:{fontSize:14,lineHeight:21},link:{textDecorationLine:"underline"},footer:{paddingTop:12,gap:4}});function em({styles:e,placeholderColor:t,hasPrefilledEmail:r,loading:o,error:n,status:i,email:s,setEmail:a,checkEmail:l,onClose:u}){let{colors:c}=V();return r?jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u}),jsxs(View,{style:e.flow.centered,children:[jsx(nt,{size:56,strokeWidth:3}),jsx(Mr,{error:n,progress:i,loading:o})]})]}):jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u}),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,o&&{opacity:.5}],placeholder:"jane@example.com",placeholderTextColor:t,keyboardType:"email-address",autoCapitalize:"none",autoCorrect:false,value:s,onChangeText:a,autoFocus:true,returnKeyType:"done",onSubmitEditing:l,editable:!o})]})]}),jsxs(View,{style:e.form.footer,children:[o?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:c.primaryForeground,gradientTo:c.primaryForeground})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!s&&e.form.continueBtnDisabled],onPress:l,disabled:!s,children:jsx(Text,{style:[e.form.continueBtnText,!s&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Mr,{error:n,progress:i,loading:o})]})]})})}function rm({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:i}){return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:i}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(nt,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Verifying identity"}),jsx(Text,{style:e.flow.sub,children:r||"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:r||"Tap below to continue verification."})]}),jsx(Mr,{error:o,progress:r,loading:false})]}),!t&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:n,children:jsx(Text,{style:e.form.continueBtnText,children:"Continue Verification"})})})]})}function nm({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:i,destinationNetwork:s,tokenIconUrl:a,networkIconUrl:l,onClose:u,onRetryStatusCheck:c}){let{colors:y}=V(),T=!!t;return jsxs(View,{style:e.form.screen,children:[T?jsx(St,{onPress:u}):jsx(View,{style:Cl}),jsx(View,{style:e.flow.centered,children:t?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(nt,{size:48,strokeWidth:3,gradientFrom:y.primary,gradientTo:y.primary})}),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."]}),n&&i&&s&&jsx(Sl,{sourceCurrency:n,destinationCurrency:i,destinationNetwork:s,tokenIconUrl:a,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(Mr,{error:t,progress:r,loading:o}),t?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:c,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function im({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:i,tokenIconUrl:s,networkIconUrl:a,onClose:l,onBack:u}){let{colors:c}=V(),y=t.transaction_details,T=bl(y.destination_amount,y.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u??l,title:"Review your purchase",variant:u?"back":"close"}),jsxs(View,{style:e.form.content,children:[jsx(View,{style:{alignItems:"center",marginTop:24,marginBottom:20},children:jsx(as,{currency:y.destination_currency,tokenIconUrl:s,networkIconUrl:a,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(To,{quote:e.quote,label:"You pay",value:`${y.source_amount} ${y.source_currency.toUpperCase()}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"You receive",value:`${T} ${y.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"Network fee",value:`$${y.fees.network_fee_amount}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"Transaction fee",value:`$${y.fees.transaction_fee_amount}`,last:true})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:c.primaryForeground,gradientTo:c.primaryForeground})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:i,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(Mr,{error:o,progress:n,loading:r})]})]})}function sm({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:i,phone:s,setPhone:a,register:l,onClose:u}){let c=V(),{colors:y,fonts:T,components:w}=c,[m,g]=useState("");useEffect(()=>{if(t)return;let b=m?`+1${m}`:"";a(b);},[m,a,t]);let h=useCallback(b=>{g(b.replace(/[^\d]/g,""));},[]);if(t)return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u}),jsxs(View,{style:e.flow.centered,children:[jsx(nt,{size:56,strokeWidth:3}),jsx(Mr,{error:o,progress:n,loading:r})]})]});let S=m.length>=4;return jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:u}),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"}),jsxs(View,{style:Sa.phoneRow,children:[jsxs(View,{style:[Sa.countryPrefix,{backgroundColor:w.card.backgroundColor,borderColor:w.input.borderColor,borderRadius:w.input.borderRadius,borderWidth:w.card.borderWidth}],children:[jsx(Text,{style:Sa.flag,children:"\u{1F1FA}\u{1F1F8}"}),jsx(Text,{style:[Sa.dialCode,{color:y.foreground,fontFamily:T.medium}],children:"+1"})]}),jsx(TextInput,{style:[e.form.input,Sa.phoneInput,r&&{opacity:.5}],placeholder:"Phone number",placeholderTextColor:c.components.input.placeholderColor,keyboardType:"phone-pad",value:m,onChangeText:h,autoFocus:true,returnKeyType:"done",onSubmitEditing:()=>S&&l(),editable:!r})]})]}),jsxs(View,{style:e.form.emailRow,children:[jsx(Text,{style:e.form.emailLabel,children:"Signing up as"}),jsx(Text,{style:e.form.emailValue,children:i})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:y.primaryForeground,gradientTo:y.primaryForeground})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!S&&e.form.continueBtnDisabled],onPress:l,disabled:!S,children:jsx(Text,{style:[e.form.continueBtnText,!S&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Mr,{error:o,progress:n,loading:r})]})]})})}var Sa=StyleSheet.create({phoneRow:{flexDirection:"row",gap:8,alignItems:"stretch"},countryPrefix:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,gap:8},flag:{fontSize:20},dialCode:{fontSize:16,fontWeight:"600"},phoneInput:{flex:1}});function ky({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=V(),n=e.toLowerCase(),i=wl[n]??o.primary,s=Math.round(r*.36);return jsxs(View,{style:{width:r,height:r,position:"relative"},children:[t?jsx(Image,{source:{uri:t},style:{width:r,height:r,borderRadius:r/2}}):jsx(View,{style:[$o.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:i}],children:jsx(Text,{style:[$o.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[$o.checkBadge,{width:s,height:s,borderRadius:s/2,backgroundColor:o.success,borderColor:o.background}],children:jsx(Le,{size:s*.55,color:"#FFFFFF",strokeWidth:3})})]})}function am({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:i,onDone:s}){let {colors:a,components:l,fonts:u}=V(),c=t.transaction_details,y=bl(c.destination_amount,c.destination_currency),T=r||o||"";ss(c.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:s,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(at,{style:e.form.flex,contentContainerStyle:$o.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:$o.iconSection,children:[jsx(ky,{currency:c.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:$o.statusRow,children:[jsx(View,{style:[$o.statusDot,{backgroundColor:a.success}]}),jsx(Text,{style:[$o.statusText,{color:a.foreground,fontFamily:u.semibold}],children:"Completed"})]}),jsx(Text,{style:[$o.subtitle,{color:a.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(Sl,{sourceCurrency:c.source_currency,destinationCurrency:c.destination_currency,destinationNetwork:c.destination_network,tokenIconUrl:n,networkIconUrl:i,style:{marginBottom:12}}),jsxs(View,{style:[e.quote.card,{borderRadius:l.card.borderRadius,borderWidth:l.card.borderWidth,borderColor:l.card.borderColor},$o.detailCard],children:[jsx(To,{quote:e.quote,label:"You Paid",value:`${c.source_amount} ${c.source_currency.toUpperCase()}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"You Received",value:`${y} ${c.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"Network Fee",value:`$${c.fees.network_fee_amount}`,hideDivider:true}),jsx(To,{quote:e.quote,label:"Transaction Fee",value:`$${c.fees.transaction_fee_amount}`,hideDivider:true}),jsx(fd,{quote:e.quote,label:"Intent Address",address:c.wallet_address,hideDivider:true}),T?jsx(fd,{quote:e.quote,label:"Recipient Address",address:T,last:true}):jsx(To,{quote:e.quote,label:"Session",value:t.id.slice(0,8)+"..."+t.id.slice(-6),last:true})]})]})}),jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:s,children:jsx(Text,{style:e.form.continueBtnText,children:"Done"})})})]})}var $o=StyleSheet.create({scrollContent:{paddingBottom:24,alignItems:"center"},iconSection:{alignItems:"center",marginTop:24,marginBottom:24},tokenCircle:{alignItems:"center",justifyContent:"center"},tokenLetter:{color:"#FFFFFF",fontWeight:"700",letterSpacing:.5},checkBadge:{position:"absolute",bottom:0,right:0,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",marginTop:16,gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16},subtitle:{fontSize:14,marginTop:4},detailCard:{width:"100%"}});function lm({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:i,walletNetwork:s,setWalletAddress:a,setWalletNetwork:l,setDestinationCurrency:u,registerWallet:c,onClose:y}){let{colors:T,components:w}=V();if(t){let m=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:y}),jsxs(View,{style:e.flow.centered,children:[!m&&jsx(nt,{size:56,strokeWidth:3}),jsx(Mr,{error:o,progress:n,loading:r})]}),m&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:c,children:jsx(Text,{style:e.form.continueBtnText,children:"Retry"})})})]})}return jsx(KeyboardAvoidingView,{style:e.form.flex,behavior:Platform.OS==="ios"?"padding":void 0,children:jsxs(View,{style:e.form.screen,children:[jsx(St,{onPress:y}),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:w.input.placeholderColor,autoCapitalize:"none",autoCorrect:false,value:i,onChangeText:a})]}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Network"}),jsx(View,{style:e.wallet.list,children:gl.map(m=>{let g=s===m.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,g&&e.wallet.rowSelected],onPress:()=>{l(m.value),u(m.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(m.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,g&&e.wallet.rowTextSelected],children:m.label}),g&&jsx(View,{style:e.wallet.checkCircle,children:jsx(Le,{size:14,color:w.container.buttonTitleColor,strokeWidth:2.5})})]},m.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(nt,{size:28,strokeWidth:2,gradientFrom:T.primaryForeground,gradientTo:T.primaryForeground})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!i&&e.form.continueBtnDisabled],onPress:c,disabled:!i,children:jsx(Text,{style:[e.form.continueBtnText,!i&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(Mr,{error:o,progress:n,loading:r})]})]})})}function Ul({config:e,onClose:t}){let r=V(),o=Wo(),{step:n,restoring:i,loading:s,status:a,error:l,email:u,phone:c,session:y,kycData:T,walletAddress:w,resolvedRecipientAddress:m,walletNetwork:g,sourceAmount:h,sourceCurrency:S,destinationCurrency:b,tokenIconUrl:p,networkIconUrl:d,applePaySupported:C,setStep:x,setEmail:_,setPhone:k,setWalletAddress:v,setWalletNetwork:M,setSourceAmount:W,setDestinationCurrency:O,checkEmail:F,register:U,attachKyc:j,verifyIdentity:le,registerWallet:Ye,collectPaymentMethod:_e,addPaymentMethod:ne,confirmCheckout:we,reset:fe,emitComplete:Pe,resumeFulfillmentPolling:$e,amountFirst:ue,customerId:J,accessToken:be,requestKYCUpgrade:vt,kycUpgradeMode:ve,logout:qe}=Fl(e),Ne=!!e?.email,Ve=!!e?.phone,ze=!!e?.publishableKey&&!!e?.externalUserId,[it,ie]=useState(void 0),[pe,et]=useState(void 0),[Ae,Ke]=useState([]),[$t,Ee]=useState(false),[Oe,ar]=useState(false),[he,X]=useState("not_started"),[Ce,pt]=useState("not_started"),[It,me]=useState("not_started"),[je,Vt]=useState(false);useEffect(()=>{n!=="kyc_offer"||!J||!be||(Vt(true),Mn(J,be).then(Se=>{let Z=Se.kyc_tiers??[],Q=Z.find(D=>D.tier==="l0"),L=Z.find(D=>D.tier==="l1"),I=Z.find(D=>D.tier==="l2");Q?.verification_status&&X(Q.verification_status),L?.verification_status&&pt(L.verification_status),I?.verification_status&&me(I.verification_status),console.log("[OnrampScreen] kyc_tiers \u2014 l0:",Q?.verification_status,"l1:",L?.verification_status,"l2:",I?.verification_status);}).catch(Se=>{console.warn("[OnrampScreen] kyc_offer customer fetch error:",Se?.message);}).finally(()=>Vt(false)),w&&bd({destinationNetwork:g||"ethereum",walletAddress:w,accessToken:be,cryptoCustomerId:J}).then(Se=>{let Z=Se.limits?.usd;if(Z?.card?.length){let Q=Math.max(...Z.card.map(L=>L.limit));ie(Q),console.log("[OnrampScreen] kyc_offer card max amount:",Q);}}).catch(Se=>{console.warn("[OnrampScreen] kyc_offer transaction_limits error:",Se?.message);}));},[n,J,be,w,g]),useEffect(()=>{if(i||n!=="session_params"||!J||!be)return;console.log("[OnrampScreen] customerId:",J);let Se=Q=>{let L=Q?.message??"";return L.includes("stripe_onramp_forbidden")||L.includes("403")},Z=Q=>{Se(Q)&&(hn(),fe());};Mn(J,be).then(Q=>{console.log("[OnrampScreen] customer:",JSON.stringify(Q,null,2));let L=Q.provided_fields??[],I=Q.verifications??[],D=L.includes("date_of_birth")||L.includes("id_number"),Fe=I.find(ke=>ke.name==="id_document_verified")?.status==="verified";Ee(D),ar(!!Fe);}).catch(Q=>{console.warn("[OnrampScreen] customer fetch error:",Q?.message),Z(Q);}),Cd(J,be).then(Q=>{console.log("[OnrampScreen] payment_tokens fetched, count:",Q.data?.length??0),Ke(Q.data??[]);}).catch(Q=>{console.warn("[OnrampScreen] payment_tokens error:",Q?.message),Z(Q);}),console.log("[OnrampScreen] walletAddress:",w,"walletNetwork:",g),w&&(console.log("[OnrampScreen] calling getTransactionLimits..."),bd({destinationNetwork:g||"ethereum",walletAddress:w,accessToken:be,cryptoCustomerId:J}).then(Q=>{console.log("[OnrampScreen] transaction_limits fetched");let L=Q.limits?.usd;if(L?.card?.length){let I=Math.max(...L.card.map(D=>D.limit));ie(I),console.log("[OnrampScreen] card max amount:",I);}}).catch(Q=>{console.warn("[OnrampScreen] transaction_limits error:",Q?.message),Z(Q);})),aa(e?.publishableKey).then(Q=>{let L=Q.data?.find(I=>I.currency_code==="usd");L&&(et(L.minimum_amount),console.log("[OnrampScreen] fiat min amount:",L.minimum_amount));}).catch(Q=>{console.warn("[OnrampScreen] fiat_currencies error:",Q?.message);});},[i,n,J,be,w,g,fe]);let ot=async()=>{if(!(!J||!be))try{let Se=await Cd(J,be);console.log("[OnrampScreen] payment_tokens refreshed, count:",Se.data?.length??0),Ke(Se.data??[]);}catch(Se){console.warn("[OnrampScreen] payment_tokens refresh error:",Se?.message);let Z=Se?.message??"";(Z.includes("stripe_onramp_forbidden")||Z.includes("403"))&&(hn(),fe());}},Lt=async()=>{let Se=await ne();return Se&&await ot(),Se},Bt=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&Bt&&y&&(Pe(y),fe(),t?.());},[n,Bt,y,Pe,fe,t]),useEffect(()=>{n==="register"&&Ve&&U();},[n,Ve,U]);let yt=()=>{fe(),t?.();};if(i)return jsx(View,{style:[Iy.container,{backgroundColor:r.colors.background}],children:jsx(nt,{size:56,strokeWidth:3,gradientFrom:r.colors.primary,gradientTo:r.colors.primary})});if(n==="disclaimer")return jsx(Xp,{styles:o,merchantDisplayName:e?.merchantDisplayName,onContinue:()=>x("register"),onClose:()=>x("email")});if(n==="email")return jsx(em,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:Ne,loading:s,error:l,status:a,email:u,setEmail:_,checkEmail:F,onClose:yt});if(n==="register")return jsx(sm,{styles:o,hasPrefilledPhone:Ve,loading:s,error:l,status:a,email:u,phone:c,setPhone:k,register:U,onClose:yt});if(n==="kyc")return jsx(Ol,{initialData:T,loading:s,onComplete:j,onCancel:yt});if(n==="kyc_offer"){let Se=()=>{ve.current&&(ve.current=false),x("session_params");};return jsx(Jp,{onSelectL1:()=>x("kyc_l1"),onSelectL2:()=>{ve.current=true,x("identity");},onSkip:Se,onClose:()=>{ve.current?(ve.current=false,x("session_params")):Se();},onRefresh:()=>{!J||!be||(Vt(true),Mn(J,be).then(L=>{let I=L.kyc_tiers??[],D=I.find(ke=>ke.tier==="l0"),q=I.find(ke=>ke.tier==="l1"),Fe=I.find(ke=>ke.tier==="l2");D?.verification_status&&X(D.verification_status),q?.verification_status&&pt(q.verification_status),Fe?.verification_status&&me(Fe.verification_status),console.log("[OnrampScreen] refresh kyc_tiers \u2014 l0:",D?.verification_status,"l1:",q?.verification_status,"l2:",Fe?.verification_status);}).catch(L=>{console.warn("[OnrampScreen] refresh customer fetch error:",L?.message);}).finally(()=>Vt(false)));},loading:s,loadingTiers:je,error:l?.message,l0Status:he,l1Status:Ce,l2Status:It,l1Completed:$t,l2Completed:Oe,currentLimit:it})}if(n==="kyc_l1"){let Se=ve.current?"session_params":"wallet";return jsx(qp,{initialData:T,loading:s,onComplete:Z=>{console.log("[KYCL1] onComplete called with:",JSON.stringify(Z)),ve.current&&(ve.current=false),j(Z,Se);},onCancel:()=>x("kyc_offer"),onClose:yt})}return n==="identity"?jsx(rm,{styles:o,loading:s,status:a,error:l,verifyIdentity:le,onClose:()=>{ve.current?(ve.current=false,x("session_params")):yt();}}):n==="wallet"?jsx(lm,{styles:o,hasAutoWallet:ze,loading:s,error:l,status:a,walletAddress:w,walletNetwork:g,setWalletAddress:v,setWalletNetwork:M,setDestinationCurrency:O,registerWallet:Ye,onClose:yt}):n==="session_params"?jsx(Pl,{initialAmount:h,currency:S,applePaySupported:C,paymentSelectorPosition:e?.paymentSelectorPosition??"header",minAmount:pe,maxAmount:it,paymentTokens:Ae,onAddPaymentMethod:Lt,onCollectPayment:(Se,Z)=>{_e(Se,Z);},paymentLoading:s,paymentStatus:a,paymentError:l?.message??null,onConfirm:(Se,Z)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:Se,selectedMethod:Z,amountFirst:ue}),ue&&!J)W(Se),x("email");else {let Q=Z==="apple_pay",L=!Q&&Z?Z:void 0;console.log("[OnrampScreen] isApplePay:",Q,"hasSavedToken:",!!L),_e(Q,Se,L);}},onCancel:yt,accessToken:be,showHistoryProgressBar:e?.showHistoryProgressBar,onLogout:qe,onRequestKYC:vt}):n==="quote"&&y?jsx(im,{styles:o,session:y,loading:s,error:l,status:a,confirmCheckout:we,tokenIconUrl:p,networkIconUrl:d,onClose:yt,onBack:()=>x("session_params")}):n==="processing"?jsx(nm,{styles:o,error:l,status:a,loading:s,sourceCurrency:y?.transaction_details.source_currency,destinationCurrency:y?.transaction_details.destination_currency??b,destinationNetwork:y?.transaction_details.destination_network??"base",tokenIconUrl:p,networkIconUrl:d,onClose:yt,onRetryStatusCheck:$e}):n==="success"&&y&&!Bt?jsx(am,{styles:o,session:y,resolvedRecipientAddress:m,recipientFromConfig:e?.recipientAddress,tokenIconUrl:p,networkIconUrl:d,onDone:()=>{Pe(y),fe(),t?.();}}):null}var Iy=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center"}});function cm(){try{let e=Py.expoConfig?.plugins;if(!Array.isArray(e))return;for(let t of e){if(!Array.isArray(t))continue;let[r,o]=t;if(r!=="@stripe/stripe-react-native"||!o||typeof o!="object")continue;let n=o.merchantIdentifier;if(typeof n=="string"){let i=n.trim();if(i.length>0)return i}}}catch{}}function Hl({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:i="ethereum",destinationChainId:s="8453",destinationTokenAddress:a,recipientAddress:l,onComplete:u,onError:c,onStepChange:y,onClose:T,merchantIdentifier:w="",urlScheme:m="unifoldOnramp",paymentSelectorPosition:g,skipSuccessConfirmation:h=false,appName:S}){let{colors:b,fonts:p,components:d}=V(),C=e||dl(),x=useMemo(()=>{let O=w.trim();return O.length>0?O:cm()??""},[w]),[_,k]=useState("loading"),[v,M]=useState(null);useEffect(()=>{let O=false;async function F(){try{C&&(kl(C),Tl(sa()));let U=await xl();if(O)return;let j=x.trim();if(await initStripe({publishableKey:U,urlScheme:m,...j?{merchantIdentifier:j}:{}}),O)return;k("ready");}catch(U){if(O)return;console.error("[StripeOnramp] Init failed:",U),M(U?.message??"Failed to load Stripe configuration"),k("error");}}return F(),()=>{O=true;}},[C,x,m]);let W=useMemo(()=>{let O={publishableKey:C,externalUserId:o,destinationChainType:i,destinationChainId:s,onComplete:u,onError:c,onStepChange:y};return a&&(O.destinationTokenAddress=a),l&&(O.recipientAddress=l),t&&(O.email=t),r&&(O.phone=r),n&&(O.flowOrder=n),g&&(O.paymentSelectorPosition=g),O.skipSuccessConfirmation=h,O.merchantIdentifier=x,S&&(O.merchantDisplayName=S),O},[C,o,i,s,a,l,t,r,n,g,h,x,S,u,c,y]);return _==="error"?jsxs(View,{style:[ys.centered,{backgroundColor:b.background}],children:[jsx(Text,{style:[ys.errorText,{color:b.error,fontFamily:p.medium}],children:"Unable to initialize"}),jsx(Text,{style:[ys.errorDetail,{color:b.foregroundMuted,fontFamily:p.regular}],children:v}),T&&jsx(TouchableOpacity,{style:[ys.retryBtn,{backgroundColor:d.button.primaryBackground,borderRadius:d.button.borderRadius}],onPress:T,children:jsx(Text,{style:[ys.retryBtnText,{color:d.button.primaryText,fontFamily:p.medium}],children:"Go Back"})})]}):_==="loading"?jsx(View,{style:[ys.centered,{backgroundColor:b.background}],children:jsx(nt,{size:56,strokeWidth:3,gradientFrom:b.primary,gradientTo:b.primary})}):jsx(Ul,{config:W,onClose:T})}var ys=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",paddingHorizontal:24},errorText:{fontSize:18,marginBottom:8},errorDetail:{fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{paddingVertical:14,paddingHorizontal:32},retryBtnText:{fontSize:16}});function mm(){let{configure:e}=useOnramp(),t=useRef(false);return useEffect(()=>{t.current||(t.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(r=>{r.error&&console.error("[StripeOnrampPreconfigure] error:",r.error.message);}).catch(r=>{console.error("[StripeOnrampPreconfigure] threw:",r?.message);}));},[e]),null}var fm="__unifold_stripe_onramp__";function Nl(e){globalThis[fm]=e;}function hm(){return globalThis[fm]}Nl(Hl);var qo=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this);}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe();}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var _i,Gn,bs,gm,Ey=(gm=class extends qo{constructor(){super();te(this,_i);te(this,Gn);te(this,bs);A(this,bs,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){f(this,Gn)||this.setEventListener(f(this,bs));}onUnsubscribe(){var t;this.hasListeners()||((t=f(this,Gn))==null||t.call(this),A(this,Gn,void 0));}setEventListener(t){var r;A(this,bs,t),(r=f(this,Gn))==null||r.call(this),A(this,Gn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){f(this,_i)!==t&&(A(this,_i,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof f(this,_i)=="boolean"?f(this,_i):globalThis.document?.visibilityState!=="hidden"}},_i=new WeakMap,Gn=new WeakMap,bs=new WeakMap,gm),Cs=new Ey;var My={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ko,Ri,ym,zy=(ym=class{constructor(){te(this,Ko,My);te(this,Ri,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&f(this,Ri)&&e!==f(this,Ko)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:f(this,Ko),provider:e}),A(this,Ko,e),process.env.NODE_ENV!=="production"&&A(this,Ri,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&A(this,Ri,true),f(this,Ko).setTimeout(e,t)}clearTimeout(e){f(this,Ko).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&A(this,Ri,true),f(this,Ko).setInterval(e,t)}clearInterval(e){f(this,Ko).clearInterval(e);}},Ko=new WeakMap,Ri=new WeakMap,ym),Qo=new zy;function bm(e){setTimeout(e,0);}var Md=typeof window>"u"||"Deno"in globalThis;function br(){}function Sm(e,t){return typeof e=="function"?e(t):e}function ka(e){return typeof e=="number"&&e>=0&&e!==1/0}function $l(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Io(e,t){return typeof e=="function"?e(t):e}function Yr(e,t){return typeof e=="function"?e(t):e}function ql(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:i,queryKey:s,stale:a}=e;if(s){if(o){if(t.queryHash!==Ta(s,t.options))return false}else if(!Pi(t.queryKey,s))return false}if(r!=="all"){let l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return false}return !(typeof a=="boolean"&&t.isStale()!==a||n&&n!==t.state.fetchStatus||i&&!i(t))}function Kl(e,t){let{exact:r,status:o,predicate:n,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return false;if(r){if(vi(t.options.mutationKey)!==vi(i))return false}else if(!Pi(t.options.mutationKey,i))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Ta(e,t){return (t?.queryKeyHashFn||vi)(e)}function vi(e){return JSON.stringify(e,(t,r)=>Ed(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function Pi(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Pi(e[r],t[r])):false}var Uy=Object.prototype.hasOwnProperty;function jl(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=Cm(e)&&Cm(t);if(!o&&!(Ed(e)&&Ed(t)))return t;let i=(o?e:Object.keys(e)).length,s=o?t:Object.keys(t),a=s.length,l=o?new Array(a):{},u=0;for(let c=0;c<a;c++){let y=o?c:s[c],T=e[y],w=t[y];if(T===w){l[y]=T,(o?c<i:Uy.call(e,y))&&u++;continue}if(T===null||w===null||typeof T!="object"||typeof w!="object"){l[y]=w;continue}let m=jl(T,w,r+1);l[y]=m,m===T&&u++;}return i===a&&u===i?e:l}function Ql(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return false;for(let r in e)if(e[r]!==t[r])return false;return true}function Cm(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ed(e){if(!wm(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!wm(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function wm(e){return Object.prototype.toString.call(e)==="[object Object]"}function km(e){return new Promise(t=>{Qo.setTimeout(t,e);})}function xa(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==false){if(process.env.NODE_ENV!=="production")try{return jl(e,t)}catch(o){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${o}`),o}return jl(e,t)}return t}function Tm(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function xm(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var Ii=Symbol();function Yl(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Ii&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ii?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Gl(e,t){return typeof e=="function"?e(...t):!!e}function _m(e,t,r){let o=false,n;return Object.defineProperty(e,"signal",{enumerable:true,get:()=>(n??(n=t()),o||(o=true,n.aborted?r():n.addEventListener("abort",r,{once:true})),n)}),e}var Yo=(()=>{let e=()=>Md;return {isServer(){return e()},setIsServer(t){e=t;}}})();function _a(){let e,t,r=new Promise((n,i)=>{e=n,t=i;});r.status="pending",r.catch(()=>{});function o(n){Object.assign(r,n),delete r.resolve,delete r.reject;}return r.resolve=n=>{o({status:"fulfilled",value:n}),e(n);},r.reject=n=>{o({status:"rejected",reason:n}),t(n);},r}var Rm=bm;function Hy(){let e=[],t=0,r=a=>{a();},o=a=>{a();},n=Rm,i=a=>{t?e.push(a):n(()=>{r(a);});},s=()=>{let a=e;e=[],a.length&&n(()=>{o(()=>{a.forEach(l=>{r(l);});});});};return {batch:a=>{let l;t++;try{l=a();}finally{t--,t||s();}return l},batchCalls:a=>(...l)=>{i(()=>{a(...l);});},schedule:i,setNotifyFunction:a=>{r=a;},setBatchNotifyFunction:a=>{o=a;},setScheduler:a=>{n=a;}}}var Ht=Hy();var ws,Jn,Ss,vm,Ny=(vm=class extends qo{constructor(){super();te(this,ws,true);te(this,Jn);te(this,Ss);A(this,Ss,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t(true),o=()=>t(false);return window.addEventListener("online",r,false),window.addEventListener("offline",o,false),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o);}}});}onSubscribe(){f(this,Jn)||this.setEventListener(f(this,Ss));}onUnsubscribe(){var t;this.hasListeners()||((t=f(this,Jn))==null||t.call(this),A(this,Jn,void 0));}setEventListener(t){var r;A(this,Ss,t),(r=f(this,Jn))==null||r.call(this),A(this,Jn,t(this.setOnline.bind(this)));}setOnline(t){f(this,ws)!==t&&(A(this,ws,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return f(this,ws)}},ws=new WeakMap,Jn=new WeakMap,Ss=new WeakMap,vm),ks=new Ny;function jy(e){return Math.min(1e3*2**e,3e4)}function zd(e){return (e??"online")==="online"?ks.isOnline():true}var Jl=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function Zl(e){let t=false,r=0,o,n=_a(),i=()=>n.status!=="pending",s=g=>{if(!i()){let h=new Jl(g);T(h),e.onCancel?.(h);}},a=()=>{t=true;},l=()=>{t=false;},u=()=>Cs.isFocused()&&(e.networkMode==="always"||ks.isOnline())&&e.canRun(),c=()=>zd(e.networkMode)&&e.canRun(),y=g=>{i()||(o?.(),n.resolve(g));},T=g=>{i()||(o?.(),n.reject(g));},w=()=>new Promise(g=>{o=h=>{(i()||u())&&g(h);},e.onPause?.();}).then(()=>{o=void 0,i()||e.onContinue?.();}),m=()=>{if(i())return;let g,h=r===0?e.initialPromise:void 0;try{g=h??e.fn();}catch(S){g=Promise.reject(S);}Promise.resolve(g).then(y).catch(S=>{if(i())return;let b=e.retry??(Yo.isServer()?0:3),p=e.retryDelay??jy,d=typeof p=="function"?p(r,S):p,C=b===true||typeof b=="number"&&r<b||typeof b=="function"&&b(r,S);if(t||!C){T(S);return}r++,e.onFail?.(r,S),km(d).then(()=>u()?void 0:w()).then(()=>{t?T(S):m();});});};return {promise:n,status:()=>n.status,cancel:s,continue:()=>(o?.(),n),cancelRetry:a,continueRetry:l,canStart:c,start:()=>(c()?m():w().then(m),n)}}var Oi,Im,Xl=(Im=class{constructor(){te(this,Oi);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),ka(this.gcTime)&&A(this,Oi,Qo.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Yo.isServer()?1/0:300*1e3));}clearGcTimeout(){f(this,Oi)!==void 0&&(Qo.clearTimeout(f(this,Oi)),A(this,Oi,void 0));}},Oi=new WeakMap,Im);var Fi,Ts,Co,Di,Ir,Ra,Vi,lo,Vm,bn,Fm,Dm=(Fm=class extends Xl{constructor(t){super();te(this,lo);te(this,Fi);te(this,Ts);te(this,Co);te(this,Di);te(this,Ir);te(this,Ra);te(this,Vi);A(this,Vi,false),A(this,Ra,t.defaultOptions),this.setOptions(t.options),this.observers=[],A(this,Di,t.client),A(this,Co,f(this,Di).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,A(this,Fi,Om(this.options)),this.state=t.state??f(this,Fi),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return f(this,Ir)?.promise}setOptions(t){if(this.options={...f(this,Ra),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=Om(this.options);r.data!==void 0&&(this.setState(Pm(r.data,r.dataUpdatedAt)),A(this,Fi,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&f(this,Co).remove(this);}setData(t,r){let o=xa(this.state.data,t,this.options);return Ue(this,lo,bn).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Ue(this,lo,bn).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=f(this,Ir)?.promise;return f(this,Ir)?.cancel(t),r?r.then(br).catch(br):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return f(this,Fi)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Yr(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ii||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Io(t.options.staleTime,this)==="static"):false}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?true:t==="static"?false:this.state.isInvalidated?true:!$l(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),f(this,Ir)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),f(this,Ir)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),f(this,Co).notify({type:"observerAdded",query:this,observer:t}));}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(f(this,Ir)&&(f(this,Vi)||Ue(this,lo,Vm).call(this)?f(this,Ir).cancel({revert:true}):f(this,Ir).cancelRetry()),this.scheduleGc()),f(this,Co).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Ue(this,lo,bn).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&f(this,Ir)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(f(this,Ir))return f(this,Ir).continueRetry(),f(this,Ir).promise}if(t&&this.setOptions(t),!this.options.queryFn){let l=this.observers.find(u=>u.options.queryFn);l&&this.setOptions(l.options);}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));let o=new AbortController,n=l=>{Object.defineProperty(l,"signal",{enumerable:true,get:()=>(A(this,Vi,true),o.signal)});},i=()=>{let l=Yl(this.options,r),c=(()=>{let y={client:f(this,Di),queryKey:this.queryKey,meta:this.meta};return n(y),y})();return A(this,Vi,false),this.options.persister?this.options.persister(l,c,this):l(c)},a=(()=>{let l={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:f(this,Di),state:this.state,fetchFn:i};return n(l),l})();this.options.behavior?.onFetch(a,this),A(this,Ts,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&Ue(this,lo,bn).call(this,{type:"fetch",meta:a.fetchOptions?.meta}),A(this,Ir,Zl({initialPromise:r?.initialPromise,fn:a.fetchFn,onCancel:l=>{l instanceof Jl&&l.revert&&this.setState({...f(this,Ts),fetchStatus:"idle"}),o.abort();},onFail:(l,u)=>{Ue(this,lo,bn).call(this,{type:"failed",failureCount:l,error:u});},onPause:()=>{Ue(this,lo,bn).call(this,{type:"pause"});},onContinue:()=>{Ue(this,lo,bn).call(this,{type:"continue"});},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>true}));try{let l=await f(this,Ir).start();if(l===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(l),f(this,Co).config.onSuccess?.(l,this),f(this,Co).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof Jl){if(l.silent)return f(this,Ir).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Ue(this,lo,bn).call(this,{type:"error",error:l}),f(this,Co).config.onError?.(l,this),f(this,Co).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},Fi=new WeakMap,Ts=new WeakMap,Co=new WeakMap,Di=new WeakMap,Ir=new WeakMap,Ra=new WeakMap,Vi=new WeakMap,lo=new WeakSet,Vm=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},bn=function(t){let r=o=>{switch(t.type){case "failed":return {...o,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case "pause":return {...o,fetchStatus:"paused"};case "continue":return {...o,fetchStatus:"fetching"};case "fetch":return {...o,...Ud(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...Pm(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return A(this,Ts,t.manual?n:void 0),n;case "error":let i=t.error;return {...o,error:i,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:true};case "invalidate":return {...o,isInvalidated:true};case "setState":return {...o,...t.state}}};this.state=r(this.state),Ht.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),f(this,Co).notify({query:this,type:"updated",action:t});});},Fm);function Ud(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:zd(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Pm(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function Om(e){let t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,o=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return {data:t,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:false,status:r?"success":"pending",fetchStatus:"idle"}}var Gr,Je,Ia,zr,Li,xs,Cn,Zn,Pa,_s,Rs,Bi,Wi,Xn,vs,ft,va,Hd,Nd,jd,$d,qd,Kd,Qd,Am,Wm,Gd=(Wm=class extends qo{constructor(t,r){super();te(this,ft);te(this,Gr);te(this,Je);te(this,Ia);te(this,zr);te(this,Li);te(this,xs);te(this,Cn);te(this,Zn);te(this,Pa);te(this,_s);te(this,Rs);te(this,Bi);te(this,Wi);te(this,Xn);te(this,vs,new Set);this.options=r,A(this,Gr,t),A(this,Zn,null),A(this,Cn,_a()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(f(this,Je).addObserver(this),Lm(f(this,Je),this.options)?Ue(this,ft,va).call(this):this.updateResult(),Ue(this,ft,$d).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Yd(f(this,Je),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Yd(f(this,Je),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Ue(this,ft,qd).call(this),Ue(this,ft,Kd).call(this),f(this,Je).removeObserver(this);}setOptions(t){let r=this.options,o=f(this,Je);if(this.options=f(this,Gr).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Yr(this.options.enabled,f(this,Je))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Ue(this,ft,Qd).call(this),f(this,Je).setOptions(this.options),r._defaulted&&!Ql(this.options,r)&&f(this,Gr).getQueryCache().notify({type:"observerOptionsUpdated",query:f(this,Je),observer:this});let n=this.hasListeners();n&&Bm(f(this,Je),o,this.options,r)&&Ue(this,ft,va).call(this),this.updateResult(),n&&(f(this,Je)!==o||Yr(this.options.enabled,f(this,Je))!==Yr(r.enabled,f(this,Je))||Io(this.options.staleTime,f(this,Je))!==Io(r.staleTime,f(this,Je)))&&Ue(this,ft,Hd).call(this);let i=Ue(this,ft,Nd).call(this);n&&(f(this,Je)!==o||Yr(this.options.enabled,f(this,Je))!==Yr(r.enabled,f(this,Je))||i!==f(this,Xn))&&Ue(this,ft,jd).call(this,i);}getOptimisticResult(t){let r=f(this,Gr).getQueryCache().build(f(this,Gr),t),o=this.createResult(r,t);return qy(this,o)&&(A(this,zr,o),A(this,xs,this.options),A(this,Li,f(this,Je).state)),o}getCurrentResult(){return f(this,zr)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&f(this,Cn).status==="pending"&&f(this,Cn).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){f(this,vs).add(t);}getCurrentQuery(){return f(this,Je)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=f(this,Gr).defaultQueryOptions(t),o=f(this,Gr).getQueryCache().build(f(this,Gr),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Ue(this,ft,va).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),f(this,zr)))}createResult(t,r){let o=f(this,Je),n=this.options,i=f(this,zr),s=f(this,Li),a=f(this,xs),u=t!==o?t.state:f(this,Ia),{state:c}=t,y={...c},T=false,w;if(r._optimisticResults){let v=this.hasListeners(),M=!v&&Lm(t,r),W=v&&Bm(t,o,r,n);(M||W)&&(y={...y,...Ud(c.data,t.options)}),r._optimisticResults==="isRestoring"&&(y.fetchStatus="idle");}let{error:m,errorUpdatedAt:g,status:h}=y;w=y.data;let S=false;if(r.placeholderData!==void 0&&w===void 0&&h==="pending"){let v;i?.isPlaceholderData&&r.placeholderData===a?.placeholderData?(v=i.data,S=true):v=typeof r.placeholderData=="function"?r.placeholderData(f(this,Rs)?.state.data,f(this,Rs)):r.placeholderData,v!==void 0&&(h="success",w=xa(i?.data,v,r),T=true);}if(r.select&&w!==void 0&&!S)if(i&&w===s?.data&&r.select===f(this,Pa))w=f(this,_s);else try{A(this,Pa,r.select),w=r.select(w),w=xa(i?.data,w,r),A(this,_s,w),A(this,Zn,null);}catch(v){A(this,Zn,v);}f(this,Zn)&&(m=f(this,Zn),w=f(this,_s),g=Date.now(),h="error");let b=y.fetchStatus==="fetching",p=h==="pending",d=h==="error",C=p&&b,x=w!==void 0,k={status:h,fetchStatus:y.fetchStatus,isPending:p,isSuccess:h==="success",isError:d,isInitialLoading:C,isLoading:C,data:w,dataUpdatedAt:y.dataUpdatedAt,error:m,errorUpdatedAt:g,failureCount:y.fetchFailureCount,failureReason:y.fetchFailureReason,errorUpdateCount:y.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:y.dataUpdateCount>u.dataUpdateCount||y.errorUpdateCount>u.errorUpdateCount,isFetching:b,isRefetching:b&&!p,isLoadingError:d&&!x,isPaused:y.fetchStatus==="paused",isPlaceholderData:T,isRefetchError:d&&x,isStale:Jd(t,r),refetch:this.refetch,promise:f(this,Cn),isEnabled:Yr(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let v=k.data!==void 0,M=k.status==="error"&&!v,W=U=>{M?U.reject(k.error):v&&U.resolve(k.data);},O=()=>{let U=A(this,Cn,k.promise=_a());W(U);},F=f(this,Cn);switch(F.status){case "pending":t.queryHash===o.queryHash&&W(F);break;case "fulfilled":(M||k.data!==F.value)&&O();break;case "rejected":(!M||k.error!==F.reason)&&O();break}}return k}updateResult(){let t=f(this,zr),r=this.createResult(f(this,Je),this.options);if(A(this,Li,f(this,Je).state),A(this,xs,this.options),f(this,Li).data!==void 0&&A(this,Rs,f(this,Je)),Ql(r,t))return;A(this,zr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,i=typeof n=="function"?n():n;if(i==="all"||!i&&!f(this,vs).size)return true;let s=new Set(i??f(this,vs));return this.options.throwOnError&&s.add("error"),Object.keys(f(this,zr)).some(a=>{let l=a;return f(this,zr)[l]!==t[l]&&s.has(l)})};Ue(this,ft,Am).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Ue(this,ft,$d).call(this);}},Gr=new WeakMap,Je=new WeakMap,Ia=new WeakMap,zr=new WeakMap,Li=new WeakMap,xs=new WeakMap,Cn=new WeakMap,Zn=new WeakMap,Pa=new WeakMap,_s=new WeakMap,Rs=new WeakMap,Bi=new WeakMap,Wi=new WeakMap,Xn=new WeakMap,vs=new WeakMap,ft=new WeakSet,va=function(t){Ue(this,ft,Qd).call(this);let r=f(this,Je).fetch(this.options,t);return t?.throwOnError||(r=r.catch(br)),r},Hd=function(){Ue(this,ft,qd).call(this);let t=Io(this.options.staleTime,f(this,Je));if(Yo.isServer()||f(this,zr).isStale||!ka(t))return;let o=$l(f(this,zr).dataUpdatedAt,t)+1;A(this,Bi,Qo.setTimeout(()=>{f(this,zr).isStale||this.updateResult();},o));},Nd=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(f(this,Je)):this.options.refetchInterval)??false},jd=function(t){Ue(this,ft,Kd).call(this),A(this,Xn,t),!(Yo.isServer()||Yr(this.options.enabled,f(this,Je))===false||!ka(f(this,Xn))||f(this,Xn)===0)&&A(this,Wi,Qo.setInterval(()=>{(this.options.refetchIntervalInBackground||Cs.isFocused())&&Ue(this,ft,va).call(this);},f(this,Xn)));},$d=function(){Ue(this,ft,Hd).call(this),Ue(this,ft,jd).call(this,Ue(this,ft,Nd).call(this));},qd=function(){f(this,Bi)!==void 0&&(Qo.clearTimeout(f(this,Bi)),A(this,Bi,void 0));},Kd=function(){f(this,Wi)!==void 0&&(Qo.clearInterval(f(this,Wi)),A(this,Wi,void 0));},Qd=function(){let t=f(this,Gr).getQueryCache().build(f(this,Gr),this.options);if(t===f(this,Je))return;let r=f(this,Je);A(this,Je,t),A(this,Ia,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},Am=function(t){Ht.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(f(this,zr));}),f(this,Gr).getQueryCache().notify({query:f(this,Je),type:"observerResultsUpdated"});});},Wm);function $y(e,t){return Yr(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function Lm(e,t){return $y(e,t)||e.state.data!==void 0&&Yd(e,t,t.refetchOnMount)}function Yd(e,t,r){if(Yr(t.enabled,e)!==false&&Io(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&Jd(e,t)}return false}function Bm(e,t,r,o){return (e!==t||Yr(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&Jd(e,r)}function Jd(e,t){return Yr(t.enabled,e)!==false&&e.isStaleByTime(Io(t.staleTime,e))}function qy(e,t){return !Ql(e.getCurrentResult(),t)}function Zd(e){return {onFetch:(t,r)=>{let o=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],s=t.state.data?.pageParams||[],a={pages:[],pageParams:[]},l=0,u=async()=>{let c=false,y=m=>{_m(m,()=>t.signal,()=>c=true);},T=Yl(t.options,t.fetchOptions),w=async(m,g,h)=>{if(c)return Promise.reject();if(g==null&&m.pages.length)return Promise.resolve(m);let b=(()=>{let x={client:t.client,queryKey:t.queryKey,pageParam:g,direction:h?"backward":"forward",meta:t.options.meta};return y(x),x})(),p=await T(b),{maxPages:d}=t.options,C=h?xm:Tm;return {pages:C(m.pages,p,d),pageParams:C(m.pageParams,g,d)}};if(n&&i.length){let m=n==="backward",g=m?Ky:Em,h={pages:i,pageParams:s},S=g(o,h);a=await w(h,S,m);}else {let m=e??i.length;do{let g=l===0?s[0]??o.initialPageParam:Em(o,a);if(l>0&&g==null)break;a=await w(a,g),l++;}while(l<m)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=u;}}}function Em(e,{pages:t,pageParams:r}){let o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,r[o],r):void 0}function Ky(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var Oa,Go,Lr,Ai,Jo,ei,Mm,zm=(Mm=class extends Xl{constructor(t){super();te(this,Jo);te(this,Oa);te(this,Go);te(this,Lr);te(this,Ai);A(this,Oa,t.client),this.mutationId=t.mutationId,A(this,Lr,t.mutationCache),A(this,Go,[]),this.state=t.state||Qy(),this.setOptions(t.options),this.scheduleGc();}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime);}get meta(){return this.options.meta}addObserver(t){f(this,Go).includes(t)||(f(this,Go).push(t),this.clearGcTimeout(),f(this,Lr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){A(this,Go,f(this,Go).filter(r=>r!==t)),this.scheduleGc(),f(this,Lr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){f(this,Go).length||(this.state.status==="pending"?this.scheduleGc():f(this,Lr).remove(this));}continue(){return f(this,Ai)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Ue(this,Jo,ei).call(this,{type:"continue"});},o={client:f(this,Oa),meta:this.options.meta,mutationKey:this.options.mutationKey};A(this,Ai,Zl({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(s,a)=>{Ue(this,Jo,ei).call(this,{type:"failed",failureCount:s,error:a});},onPause:()=>{Ue(this,Jo,ei).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>f(this,Lr).canRun(this)}));let n=this.state.status==="pending",i=!f(this,Ai).canStart();try{if(n)r();else {Ue(this,Jo,ei).call(this,{type:"pending",variables:t,isPaused:i}),f(this,Lr).config.onMutate&&await f(this,Lr).config.onMutate(t,this,o);let a=await this.options.onMutate?.(t,o);a!==this.state.context&&Ue(this,Jo,ei).call(this,{type:"pending",context:a,variables:t,isPaused:i});}let s=await f(this,Ai).start();return await f(this,Lr).config.onSuccess?.(s,t,this.state.context,this,o),await this.options.onSuccess?.(s,t,this.state.context,o),await f(this,Lr).config.onSettled?.(s,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(s,null,t,this.state.context,o),Ue(this,Jo,ei).call(this,{type:"success",data:s}),s}catch(s){try{await f(this,Lr).config.onError?.(s,t,this.state.context,this,o);}catch(a){Promise.reject(a);}try{await this.options.onError?.(s,t,this.state.context,o);}catch(a){Promise.reject(a);}try{await f(this,Lr).config.onSettled?.(void 0,s,this.state.variables,this.state.context,this,o);}catch(a){Promise.reject(a);}try{await this.options.onSettled?.(void 0,s,t,this.state.context,o);}catch(a){Promise.reject(a);}throw Ue(this,Jo,ei).call(this,{type:"error",error:s}),s}finally{f(this,Lr).runNext(this);}}},Oa=new WeakMap,Go=new WeakMap,Lr=new WeakMap,Ai=new WeakMap,Jo=new WeakSet,ei=function(t){let r=o=>{switch(t.type){case "failed":return {...o,failureCount:t.failureCount,failureReason:t.error};case "pause":return {...o,isPaused:true};case "continue":return {...o,isPaused:false};case "pending":return {...o,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case "success":return {...o,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:false};case "error":return {...o,data:void 0,error:t.error,failureCount:o.failureCount+1,failureReason:t.error,isPaused:false,status:"error"}}};this.state=r(this.state),Ht.batch(()=>{f(this,Go).forEach(o=>{o.onMutationUpdate(t);}),f(this,Lr).notify({mutation:this,type:"updated",action:t});});},Mm);function Qy(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var wn,Po,Fa,Um,Hm=(Um=class extends qo{constructor(t={}){super();te(this,wn);te(this,Po);te(this,Fa);this.config=t,A(this,wn,new Set),A(this,Po,new Map),A(this,Fa,0);}build(t,r,o){let n=new zm({client:t,mutationCache:this,mutationId:++Js(this,Fa)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){f(this,wn).add(t);let r=ec(t);if(typeof r=="string"){let o=f(this,Po).get(r);o?o.push(t):f(this,Po).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(f(this,wn).delete(t)){let r=ec(t);if(typeof r=="string"){let o=f(this,Po).get(r);if(o)if(o.length>1){let n=o.indexOf(t);n!==-1&&o.splice(n,1);}else o[0]===t&&f(this,Po).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=ec(t);if(typeof r=="string"){let n=f(this,Po).get(r)?.find(i=>i.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=ec(t);return typeof r=="string"?f(this,Po).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){Ht.batch(()=>{f(this,wn).forEach(t=>{this.notify({type:"removed",mutation:t});}),f(this,wn).clear(),f(this,Po).clear();});}getAll(){return Array.from(f(this,wn))}find(t){let r={exact:true,...t};return this.getAll().find(o=>Kl(r,o))}findAll(t={}){return this.getAll().filter(r=>Kl(t,r))}notify(t){Ht.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return Ht.batch(()=>Promise.all(t.map(r=>r.continue().catch(br))))}},wn=new WeakMap,Po=new WeakMap,Fa=new WeakMap,Um);function ec(e){return e.options.scope?.id}var Zo,Nm,jm=(Nm=class extends qo{constructor(t={}){super();te(this,Zo);this.config=t,A(this,Zo,new Map);}build(t,r,o){let n=r.queryKey,i=r.queryHash??Ta(n,r),s=this.get(i);return s||(s=new Dm({client:t,queryKey:n,queryHash:i,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(s)),s}add(t){f(this,Zo).has(t.queryHash)||(f(this,Zo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=f(this,Zo).get(t.queryHash);r&&(t.destroy(),r===t&&f(this,Zo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){Ht.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return f(this,Zo).get(t)}getAll(){return [...f(this,Zo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>ql(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>ql(t,o)):r}notify(t){Ht.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){Ht.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){Ht.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Zo=new WeakMap,Nm);var ir,ti,ri,Is,Ps,oi,Os,Fs,$m,Xd=($m=class{constructor(e={}){te(this,ir);te(this,ti);te(this,ri);te(this,Is);te(this,Ps);te(this,oi);te(this,Os);te(this,Fs);A(this,ir,e.queryCache||new jm),A(this,ti,e.mutationCache||new Hm),A(this,ri,e.defaultOptions||{}),A(this,Is,new Map),A(this,Ps,new Map),A(this,oi,0);}mount(){Js(this,oi)._++,f(this,oi)===1&&(A(this,Os,Cs.subscribe(async e=>{e&&(await this.resumePausedMutations(),f(this,ir).onFocus());})),A(this,Fs,ks.subscribe(async e=>{e&&(await this.resumePausedMutations(),f(this,ir).onOnline());})));}unmount(){var e,t;Js(this,oi)._--,f(this,oi)===0&&((e=f(this,Os))==null||e.call(this),A(this,Os,void 0),(t=f(this,Fs))==null||t.call(this),A(this,Fs,void 0));}isFetching(e){return f(this,ir).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return f(this,ti).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return f(this,ir).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=f(this,ir).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(Io(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return f(this,ir).findAll(e).map(({queryKey:t,state:r})=>{let o=r.data;return [t,o]})}setQueryData(e,t,r){let o=this.defaultQueryOptions({queryKey:e}),i=f(this,ir).get(o.queryHash)?.state.data,s=Sm(t,i);if(s!==void 0)return f(this,ir).build(this,o).setData(s,{...r,manual:true})}setQueriesData(e,t,r){return Ht.batch(()=>f(this,ir).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return f(this,ir).get(t.queryHash)?.state}removeQueries(e){let t=f(this,ir);Ht.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=f(this,ir);return Ht.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=Ht.batch(()=>f(this,ir).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(br).catch(br)}invalidateQueries(e,t={}){return Ht.batch(()=>(f(this,ir).findAll(e).forEach(r=>{r.invalidate();}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){let r={...t,cancelRefetch:t.cancelRefetch??true},o=Ht.batch(()=>f(this,ir).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(br)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(o).then(br)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=f(this,ir).build(this,t);return r.isStaleByTime(Io(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(br).catch(br)}fetchInfiniteQuery(e){return e.behavior=Zd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(br).catch(br)}ensureInfiniteQueryData(e){return e.behavior=Zd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ks.isOnline()?f(this,ti).resumePausedMutations():Promise.resolve()}getQueryCache(){return f(this,ir)}getMutationCache(){return f(this,ti)}getDefaultOptions(){return f(this,ri)}setDefaultOptions(e){A(this,ri,e);}setQueryDefaults(e,t){f(this,Is).set(vi(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...f(this,Is).values()],r={};return t.forEach(o=>{Pi(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){f(this,Ps).set(vi(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...f(this,Ps).values()],r={};return t.forEach(o=>{Pi(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...f(this,ri).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Ta(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Ii&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...f(this,ri).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){f(this,ir).clear(),f(this,ti).clear();}},ir=new WeakMap,ti=new WeakMap,ri=new WeakMap,Is=new WeakMap,Ps=new WeakMap,oi=new WeakMap,Os=new WeakMap,Fs=new WeakMap,$m);var eu=ni.createContext(void 0),tu=e=>{let t=ni.useContext(eu);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ru=({client:e,children:t})=>(ni.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(eu.Provider,{value:e,children:t}));var qm=ni.createContext(false),Km=()=>ni.useContext(qm);qm.Provider;function Gy(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var Jy=ni.createContext(Gy()),Qm=()=>ni.useContext(Jy);var Gm=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?Gl(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},Jm=e=>{ni.useEffect(()=>{e.clearReset();},[e]);},Zm=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||Gl(r,[e.error,o]));var Xm=e=>{if(e.suspense){let r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3));}},ef=(e,t)=>e.isLoading&&e.isFetching&&!t,tf=(e,t)=>e?.suspense&&t.isPending,ou=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function rf(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');let o=Km(),n=Qm(),i=tu(),s=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(s);let a=i.getQueryCache().get(s.queryHash);process.env.NODE_ENV!=="production"&&(s.queryFn||console.error(`[${s.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),s._optimisticResults=o?"isRestoring":"optimistic",Xm(s),Gm(s,n,a),Jm(n);let l=!i.getQueryCache().get(s.queryHash),[u]=ni.useState(()=>new t(i,s)),c=u.getOptimisticResult(s),y=!o&&e.subscribed!==false;if(ni.useSyncExternalStore(ni.useCallback(T=>{let w=y?u.subscribe(Ht.batchCalls(T)):br;return u.updateResult(),w},[u,y]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),ni.useEffect(()=>{u.setOptions(s);},[s,u]),tf(s,c))throw ou(s,u,n);if(Zm({result:c,errorResetBoundary:n,throwOnError:s.throwOnError,query:a,suspense:s.suspense}))throw c.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(s,c),s.experimental_prefetchInRender&&!Yo.isServer()&&ef(c,o)&&(l?ou(s,u,n):a?.promise)?.catch(br).finally(()=>{u.updateResult();}),s.notifyOnChangeProps?c:u.trackResult(c)}function Sn(e,t){return rf(e,Gd)}var Ls=new Map;function of({width:e,height:t,borderRadius:r,color:o}){let n=useRef(new Animated.Value(.3)).current;return useEffect(()=>{let i=Animated.loop(Animated.sequence([Animated.timing(n,{toValue:.7,duration:800,useNativeDriver:true}),Animated.timing(n,{toValue:.3,duration:800,useNativeDriver:true})]));return i.start(),()=>i.stop()},[n]),jsx(Animated.View,{style:{position:"absolute",width:e,height:t,borderRadius:r,backgroundColor:o,opacity:n}})}function si({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:i="transparent",backgroundColor:s="transparent",style:a}){let{colors:l}=V(),[u,c]=useState(false),[y,T]=useState(false),[w,m]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let C=Ls.get(e);return C?{uri:e,xml:C}:null}),g=e?.toLowerCase().endsWith(".svg"),h=g&&e&&w?.uri===e?w.xml:null;useEffect(()=>{c(false),T(false);},[e]),useEffect(()=>{if(!g||!e)return;if(Ls.has(e)){m({uri:e,xml:Ls.get(e)});return}let C=false;return fetch(e).then(x=>{if(!x.ok)throw new Error(`HTTP ${x.status}`);return x.text()}).then(x=>{C||(Ls.set(e,x),m({uri:e,xml:x}));}).catch(()=>{C||c(true);}),()=>{C=true;}},[e,g]);let S=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:S},a]});let b={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:i,backgroundColor:s,overflow:"hidden",alignItems:"center",justifyContent:"center",...a},p=t-n*2,d=r-n*2;return u?jsx(View,{style:[b,{backgroundColor:s||S}]}):g?jsxs(View,{style:b,children:[!!!h&&jsx(of,{width:p,height:d,borderRadius:o,color:S}),h?jsx(SvgXml,{xml:h,width:p,height:d,onError:()=>c(true)}):jsx(SvgUri,{uri:e,width:p,height:d,onError:()=>c(true)})]}):jsxs(View,{style:b,children:[!y&&jsx(of,{width:p,height:d,borderRadius:o,color:S}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:p,height:d},resizeMode:"contain",onLoad:()=>T(true),onError:()=>c(true)})]})}function su(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(Ls.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{Ls.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function Ur({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:i,badge:s,showBalance:a=false,balanceAddress:l,balanceChainType:u,balanceChainId:c,balanceTokenAddress:y,publishableKey:T,projectName:w,leftIcon:m,onLeftAction:g}){let{colors:h,fonts:S,components:b}=V(),[p,d]=useState(null),[C,x]=useState(false),_=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!C)return;let v=Animated.loop(Animated.sequence([Animated.timing(_,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(_,{toValue:0,duration:700,useNativeDriver:true})]));return v.start(),()=>v.stop()},[C,_]),useEffect(()=>{if(!a||!l||!u||!c||!y||!T){d(null),x(false);return}let v=false;return x(true),hl(l,u,c,y,T).then(M=>{if(v)return;let W=M.balance,O=null;W&&(W.amount_usd!=null&&W.amount_usd!==""?O=`$${W.amount_usd}`:O="$0.00"),d(O);}).catch(()=>{v||d(null);}).finally(()=>{v||x(false);}),()=>{v=true;}},[a,l,u,c,y,T]);let k=_.interpolate({inputRange:[0,1],outputRange:[.4,1]});return jsxs(View,{style:Br.header,children:[jsx(View,{style:Br.leftContainer,children:r&&n?jsx(TouchableOpacity,{onPress:n,style:[Br.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Xs,{size:20,color:b.header.buttonColor,strokeWidth:2})}):m&&g?jsx(TouchableOpacity,{onPress:g,style:[Br.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:m}):jsx(View,{style:Br.spacer})}),jsxs(View,{style:Br.titleContainer,children:[jsxs(View,{style:Br.titleRow,children:[jsx(Text,{style:[Br.title,{color:b.header.titleColor,fontFamily:S.medium}],children:e}),s&&s.count>0&&jsx(View,{style:[Br.titleBadge,{backgroundColor:h.card}],children:jsx(Text,{style:[Br.titleBadgeText,{color:h.foregroundMuted,fontFamily:S.regular}],children:s.count})})]}),t?jsx(Text,{style:[Br.balanceText,{color:h.foregroundMuted,fontFamily:S.regular}],children:t}):null,a&&(C?jsx(Animated.View,{style:[Br.balanceSkeleton,{backgroundColor:h.cardHover,opacity:k}]}):p!=null?jsxs(Text,{style:[Br.balanceText,{color:h.foregroundMuted,fontFamily:S.regular}],children:[w?`${w} `:"","Balance: ",p]}):null)]}),jsx(View,{style:Br.rightContainer,children:o?jsx(TouchableOpacity,{onPress:i,style:[Br.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:b.header.buttonColor,strokeWidth:2})}):jsx(View,{style:Br.spacer})})]})}var Br=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},leftContainer:{width:40,alignItems:"flex-start"},rightContainer:{width:40,alignItems:"flex-end"},titleContainer:{flex:1,alignItems:"center"},titleRow:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},balanceSkeleton:{height:10,width:120,borderRadius:5,marginTop:4},balanceText:{fontSize:14,marginTop:3,textAlign:"center"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function Cr({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:i}){let{components:s}=V(),a=i??s.card,l=a.backShadowColor!=="transparent",u={backgroundColor:a.backgroundColor,borderRadius:a.borderRadius,borderWidth:a.borderWidth,borderColor:a.borderColor},c=[lf.wrapper,t,l&&{marginBottom:a.backShadowSpacing}],y=[u,r];return jsxs(View,{style:c,children:[l&&jsx(View,{style:[lf.backShadow,{top:a.backShadowOffset.top,left:a.backShadowOffset.left,right:a.backShadowOffset.right,bottom:a.backShadowOffset.bottom,backgroundColor:a.backShadowColor,borderRadius:a.borderRadius}]}),o!=null?jsx(TouchableOpacity$1,{onPress:o,activeOpacity:n,style:y,children:e}):jsx(View,{style:y,children:e})]})}var lf=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function Va({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:i}=V(),s=i.depositMenu.card,a=o?[...o].sort((l,u)=>l.position-u.position):[];return jsxs(Cr,{cardTokens:s,onPress:e,style:Xo.wrapper,contentStyle:Xo.container,children:[jsxs(View,{style:Xo.leftContent,children:[jsx(View,{style:[Xo.iconContainer,{borderRadius:s.iconContainerBorderRadius}],children:jsx(Yc,{size:20,color:s.iconColor,strokeWidth:2})}),jsxs(View,{style:Xo.textContainer,children:[jsx(Text,{style:[Xo.title,{color:s.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Xo.subtitle,{color:s.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Xo.rightContent,children:jsx(View,{style:Xo.networkIcons,children:a.map((l,u)=>{let c=l.icon_urls.find(y=>y.format==="png")?.url||l.icon_urls.find(y=>y.format==="svg")?.url;return jsx(View,{style:[Xo.networkIconWrapper,{marginLeft:u===0?0:-6,zIndex:a.length-u}],children:jsx(si,{uri:oe(c),width:20,height:20})},l.name)})})})]})}var Xo=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},networkIcons:{flexDirection:"row",alignItems:"center"},networkIconWrapper:{}});function Ba({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:i}=V(),s=i.depositMenu.card;return jsxs(Cr,{cardTokens:s,onPress:e,style:kn.wrapper,contentStyle:kn.container,children:[jsxs(View,{style:kn.leftContent,children:[jsx(View,{style:[kn.iconContainer,{borderRadius:s.iconContainerBorderRadius}],children:jsx(Ji,{size:20,color:s.iconColor,strokeWidth:2})}),jsxs(View,{style:kn.textContainer,children:[jsx(Text,{style:[kn.title,{color:s.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[kn.subtitle,{color:s.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:kn.rightContent,children:jsx(View,{style:kn.paymentIcons,children:o?.map(a=>{let l=a.icon_urls.find(u=>u.format==="png")?.url||a.icon_urls.find(u=>u.format==="svg")?.url;return jsx(si,{uri:oe(l),width:32,height:20,borderRadius:4},a.name)})})})]})}var kn=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},paymentIcons:{flexDirection:"row",alignItems:"center",gap:6}});function Wa({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:i}=V(),s=i.depositMenu.card;return jsx(Cr,{cardTokens:s,onPress:e,style:Tn.wrapper,contentStyle:Tn.container,children:jsxs(View,{style:Tn.leftContent,children:[jsxs(View,{style:[Tn.iconContainer,{borderRadius:s.iconContainerBorderRadius}],children:[jsx(Nr,{size:20,color:s.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[Tn.badge,{backgroundColor:s.iconColor,borderRadius:i.badge.borderRadius}],children:jsx(Text,{style:[Tn.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:Tn.textContainer,children:[jsx(Text,{style:[Tn.title,{color:s.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Tn.subtitle,{color:s.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var Tn=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,alignItems:"center",justifyContent:"center",paddingHorizontal:4},badgeText:{color:"#FFFFFF",fontSize:10,fontWeight:"600"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"}});function Ea({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=V(),i=n.depositMenu.card;return jsxs(Cr,{cardTokens:i,onPress:e,style:en.wrapper,contentStyle:en.container,children:[jsxs(View,{style:en.leftContent,children:[jsx(View,{style:[en.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(al,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:en.textContainer,children:[jsx(Text,{style:[en.title,{color:i.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[en.subtitle,{color:i.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:en.rightContent,children:jsx(View,{style:en.badge,children:jsx(Text,{style:[en.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}var en=StyleSheet.create({wrapper:{marginHorizontal:16},container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,alignItems:"center",justifyContent:"center"},textContainer:{flex:1},title:{fontSize:14,fontWeight:"400",marginBottom:2},subtitle:{fontSize:12,fontWeight:"300"},rightContent:{flexDirection:"row",alignItems:"center",gap:8},badge:{paddingHorizontal:10,paddingVertical:4,borderRadius:6,backgroundColor:"#635BFF"},badgeText:{fontSize:12,fontWeight:"600",color:"#FFFFFF"}});var pf=1e4,mf=2500,ff=3e3,hf=6e4;function Ma(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:i,modalOpenedAt:s,depositWalletId:a,depositExecutions:l,trackedExecutions:u,setDepositExecutions:c,setTrackedExecutions:y,setLatestExecution:T,setShowStatusSheet:w,onDepositSuccess:m,onExecutionsChange:g,onDepositError:h}=e,[S,b]=useState(false),[p,d]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;b(false),t==="auto_ui"&&d(false);let x=setTimeout(()=>{b(true),t==="auto_ui"&&d(true);},pf);return ()=>clearTimeout(x)},[t,r,o]),useEffect(()=>{if(!n||!s)return;let x=new Date(s.getTime()-hf),_=setInterval(async()=>{try{let M=[...(await pn(n,i)).data??[]].sort((O,F)=>{let U=O.created_at?new Date(O.created_at).getTime():0;return (F.created_at?new Date(F.created_at).getTime():0)-U}),W=null;for(let O of M){let F=O.created_at?new Date(O.created_at):null;if(!F||F<=x)continue;let U=u.get(O.id);if(!U){W=O;break}if(["pending","waiting","delayed"].includes(U)&&O.status==="succeeded"){W=O;break}}if(W){let O=W;c(F=>{let U=F.findIndex(j=>j.id===O.id);if(U>=0){let j=[...F];return j[U]=O,j}return [...F,O]}),y(F=>{let U=new Map(F);return U.set(O.id,O.status),U}),T(O),w(!0),O.status==="succeeded"&&m?.({message:"Deposit completed successfully",executionId:O.id}),g?.([...l,O]);}}catch(k){h?.({message:"Failed to check deposit status",error:k});}},mf);return ()=>clearInterval(_)},[n,i,s,u,l,g,m,h]),useEffect(()=>{if(!S||!a)return;let x=async()=>{try{await ul(a,i);}catch{}};x();let _=setInterval(x,ff);return ()=>clearInterval(_)},[S,a,i]),{pollingEnabled:S,showWaitingUi:p,handleIveDeposited:()=>{b(true),d(true);}}}function Es({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:i,isDark:s}=V(),a=s?"#1a1a1a":"#ffffff",l=s?"#ffffff":"#000000",u=n||a;return jsxs(View,{style:[yf.container,{width:t,height:t}],children:[jsx(db,{value:e||"placeholder",size:t,backgroundColor:a,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[yf.logoContainer,{width:o+12,height:o+12,backgroundColor:u,borderRadius:(o+12)/2}],children:jsx(si,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var yf=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function wf(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function fb(e){let r=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],o=e.getDate(),n=e.getFullYear(),i=e.getHours(),s=e.getMinutes(),a=i>=12?"pm":"am";i=i%12,i=i||12;let l=s<10?`0${s}`:s;return `${r} ${o}, ${n} at ${i}:${l}${a}`}function Ms({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:i,amountUsd:s,onClose:a,borderTopLeftRadius:l,borderTopRightRadius:u}){let{colors:c,fonts:y,components:T}=V(),[w,m]=useState(false),g=t==="pending"||t==="waiting"||t==="delayed",h=t==="succeeded",S=()=>{o&&Linking.openURL(o);},b=()=>{n&&Linking.openURL(n);};return jsx(bt,{visible:e,onClose:a,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:u,children:jsxs(View,{style:Zt.container,children:[jsx(TouchableOpacity,{style:Zt.closeButton,onPress:a,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.header.buttonColor,strokeWidth:2})}),jsx(View,{style:Zt.iconContainer,children:g?jsx(nt,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:oe(r)},style:Zt.tokenIconFill}):jsx(View,{style:[Zt.tokenIconFill,{backgroundColor:c.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:oe(r)},style:Zt.tokenIconLarge}):jsx(View,{style:[Zt.tokenIconLarge,{backgroundColor:c.cardHover}]}),jsx(View,{style:[Zt.statusBadge,{backgroundColor:T.container.iconBackgroundColor}],children:jsx(Le,{size:16,color:T.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[Zt.title,{color:T.container.titleColor,fontFamily:y.semibold}],children:g?"Deposit Processing":"Deposit Complete"}),s!==void 0&&jsxs(Text,{style:[Zt.amount,{color:T.container.titleColor,fontFamily:y.bold}],children:["$",s.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),i&&jsx(Text,{style:[Zt.date,{color:T.container.subtitleColor,fontFamily:y.regular}],children:fb(i)}),jsx(Text,{style:[Zt.subtitle,{color:T.container.subtitleColor,fontFamily:y.regular}],children:g?"This usually takes less than a minute.":"Your account has been credited successfully!"}),h&&(o||n)&&jsxs(View,{style:Zt.detailsSection,children:[jsx(View,{style:[Zt.divider,{backgroundColor:c.border}]}),jsxs(TouchableOpacity,{style:Zt.detailsToggle,onPress:()=>m(!w),children:[jsx(Text,{style:[Zt.detailsToggleText,{color:T.container.actionTitle,fontFamily:y.medium}],children:w?"See less":"See more details"}),w?jsx(Vo,{size:18,color:T.container.actionColor,strokeWidth:2}):jsx(Gt,{size:18,color:T.container.actionColor,strokeWidth:2})]}),w&&jsxs(View,{style:Zt.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[Zt.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:S,children:[jsx(Text,{style:[Zt.txLabel,{color:T.card.titleColor,fontFamily:y.medium}],children:"Deposit tx"}),jsx(Text,{style:[Zt.txHash,{color:T.card.subtitleColor,fontFamily:y.regular}],children:wf(o)}),jsx(Do,{size:16,color:T.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[Zt.txButton,{backgroundColor:T.card.backgroundColor,borderColor:c.border}],onPress:b,children:[jsx(Text,{style:[Zt.txLabel,{color:T.card.titleColor,fontFamily:y.medium}],children:"Completion tx"}),jsx(Text,{style:[Zt.txHash,{color:T.card.subtitleColor,fontFamily:y.regular}],children:wf(n)}),jsx(Do,{size:16,color:T.card.actionColor,strokeWidth:2})]})]})]})]})})}var Zt=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:40},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconContainer:{position:"relative",marginBottom:16},tokenIcon:{width:64,height:64,borderRadius:32},tokenIconLarge:{width:68,height:68,borderRadius:34},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},statusBadge:{position:"absolute",bottom:-2,right:-2,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center"},title:{fontSize:18,fontWeight:"600",marginBottom:4,textAlign:"center"},amount:{fontSize:28,fontWeight:"700",marginBottom:4,textAlign:"center"},date:{fontSize:13,textAlign:"center",marginBottom:12},detailsSection:{width:"100%",marginTop:16,paddingHorizontal:16},divider:{height:1,width:"100%",opacity:.15},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingVertical:12},detailsToggleText:{fontSize:14,fontWeight:"500"},txButtonsContainer:{width:"100%",gap:10,marginTop:10},txButton:{flexDirection:"row",alignItems:"center",width:"100%",paddingVertical:12,paddingHorizontal:14,borderRadius:10,borderWidth:1,gap:8},txLabel:{fontSize:14,fontWeight:"500"},txHash:{fontSize:14,flex:1,textAlign:"right"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,paddingTop:8},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,paddingHorizontal:20,borderRadius:10,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},successButton:{backgroundColor:"#22C55E"},buttonText:{color:"#fff",fontSize:14,fontWeight:"600"},hint:{fontSize:12,marginTop:12,textAlign:"center"}});function ac({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:i,fonts:s,components:a}=V();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[zi.iveDepositedButton,{backgroundColor:i.primary,borderRadius:a.button.borderRadius,borderWidth:a.button.borderWidth,borderColor:a.button.borderColor}],children:jsx(Text,{style:[zi.iveDepositedButtonText,{color:i.primaryForeground??"#FFF",fontFamily:s.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[zi.processingCard,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor,shadowColor:a.card.shadowOpacity>0?a.card.shadowColor:void 0,shadowOffset:a.card.shadowOpacity>0?a.card.shadowOffset:void 0,shadowOpacity:a.card.shadowOpacity,shadowRadius:a.card.shadowRadius,elevation:a.card.elevation}],children:[jsx(View,{style:[zi.detailIcon,{backgroundColor:a.card.iconBackgroundColor,borderRadius:a.card.iconContainerBorderRadius}],children:jsx(Gc,{size:14,color:a.card.iconColor,strokeWidth:2})}),jsxs(View,{style:zi.processingCardText,children:[jsx(Text,{style:[zi.processingCardTitle,{color:a.card.titleColor,fontFamily:s.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[zi.processingCardSubtitle,{color:a.card.subtitleColor,fontFamily:s.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var zi=StyleSheet.create({iveDepositedButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginBottom:12},iveDepositedButtonText:{fontSize:16},processingCard:{flexDirection:"row",alignItems:"center",padding:12,marginBottom:12,gap:12},processingCardText:{flex:1,gap:4},processingCardTitle:{fontSize:14},processingCardSubtitle:{fontSize:12,lineHeight:18},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"}});var za=(e,t)=>`${t}:${e}`,Tb=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function cc({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:i,destinationTokenSymbol:s,defaultChainType:a,defaultChainId:l,defaultTokenAddress:u,depositConfirmationMode:c="auto_ui",onExecutionsChange:y,onDepositSuccess:T,onDepositError:w,borderTopLeftRadius:m,borderTopRightRadius:g,sheetBorderRadius:h}){let{colors:S,fonts:b,components:p}=V(),d=a&&l?`${a}:${l}`:"solana:mainnet",[C,x]=useState("USDC"),[_,k]=useState(d),[v,M]=useState([]),[W,O]=useState(true),[F,U]=useState([]),[j,le]=useState(true),[Ye,_e]=useState(false),[ne,we]=useState(false),[fe,Pe]=useState(false),[$e,ue]=useState(false),[J,be]=useState([]),[vt,ve]=useState(new Map),[qe]=useState(()=>new Date),[Ne,Ve]=useState(null),[ze,it]=useState(false),[ie,pe]=useState(null),[et,Ae]=useState(false),Ke=new Map;F.forEach(L=>{L.chains.forEach(I=>{let D=`${I.chain_type}:${I.chain_id}`;Ke.has(D)||Ke.set(D,I);});});let $t=Array.from(Ke.values()),Ee=Tb(_),ar=$t.find(L=>L.chain_type===Ee.chainType&&L.chain_id===Ee.chainId)?.chain_type||"ethereum",he=un(v,ar),X=he?.address||"",Ce=useRef(false);useEffect(()=>{async function L(){try{le(!0),Ve(null);let D=await Ci(t,i&&n&&o?{destination_token_address:i,destination_chain_id:n,destination_chain_type:o}:void 0);if(U(D.data),D.data.length>0&&!Ce.current){Ce.current=!0;let q,Fe;if(a&&l)if(u)for(let ke of D.data){let pr=ke.chains.find(ce=>ce.chain_type===a&&ce.chain_id===l&&ce.token_address.toLowerCase()===u.toLowerCase());if(pr){q=ke,Fe=pr;break}}else for(let ke of D.data){let pr=ke.chains.find(ce=>ce.chain_type===a&&ce.chain_id===l);if(pr){q=ke,Fe=pr;break}}if(!q&&i)for(let ke of D.data){let pr=ke.chains.find(ce=>ce.token_address.toLowerCase()===i.toLowerCase());if(pr){q=ke,Fe=pr;break}}q||(q=D.data.find(ke=>ke.symbol==="USDC"),q&&q.chains.length>0&&(Fe=q.chains[0])),q||(q=D.data.find(ke=>ke.symbol==="USDT"),q&&q.chains.length>0&&(Fe=q.chains[0])),q||(q=D.data[0],q.chains.length>0&&(Fe=q.chains[0])),q&&x(q.symbol),Fe&&k(za(Fe.chain_id,Fe.chain_type));}}catch(I){console.error("Error fetching supported tokens:",I),Ve("Failed to load supported tokens"),w?.({message:"Failed to load supported tokens",error:I});}finally{le(false);}}L();},[t,w,a,l,u,i,n,o]),useEffect(()=>{async function L(){try{O(!0),Ve(null);let I=await dn({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:i},t);M(I.data);}catch(I){console.error("Error fetching wallets:",I),Ve("Failed to load wallets"),w?.({message:"Failed to load wallets",error:I});}finally{O(false);}}L();},[e,r,o,n,i,t,w]);let pt=he?.id??"",{showWaitingUi:It,handleIveDeposited:me}=Ma({depositConfirmationMode:c,depositAddress:X,chain:_,externalUserId:e,publishableKey:t,modalOpenedAt:qe,depositWalletId:pt,depositExecutions:J,trackedExecutions:vt,setDepositExecutions:be,setTrackedExecutions:ve,setLatestExecution:pe,setShowStatusSheet:it,onDepositSuccess:T,onExecutionsChange:y,onDepositError:w});useEffect(()=>{if(!F.length)return;let L=F.find(D=>D.symbol===C);if(!L||L.chains.length===0)return;if(!L.chains.some(D=>za(D.chain_id,D.chain_type)===_)){let D=L.chains[0];k(za(D.chain_id,D.chain_type));}},[C,F,_]);let je=F.find(L=>L.symbol===C),Vt=je?.chains||[],ot=Vt.find(L=>za(L.chain_id,L.chain_type)===_),Lt=async()=>{if(X)try{Clipboard.setString(X),_e(!0),setTimeout(()=>_e(!1),2e3);}catch(L){console.error("Failed to copy:",L);}},Bt=ot?.estimated_price_impact_percent??0,yt=ot?.max_slippage_percent??.25,Se=ot?.minimum_deposit_amount_usd??3;if(j)return jsxs(View,{style:B.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:S.primary}),jsx(Text,{style:[B.loadingText,{color:S.foregroundMuted,fontFamily:b.regular}],children:"Loading currencies..."})]});if(Ne&&F.length===0)return jsxs(View,{style:B.errorContainer,children:[jsx(Text,{style:[B.errorText,{color:S.error,fontFamily:b.regular}],children:Ne}),jsx(Text,{style:[B.errorHint,{color:S.foregroundMuted,fontFamily:b.regular}],children:"Please check your network connection and try again."})]});let Z=()=>jsxs(bt,{visible:fe,onClose:()=>Pe(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.tokenSelector?.borderTopLeftRadius??m,borderTopRightRadius:h?.tokenSelector?.borderTopRightRadius??g,children:[jsxs(View,{style:[B.sheetHeader,{borderBottomColor:S.border}],children:[jsx(View,{style:B.sheetHeaderSpacer}),jsx(Text,{style:[B.sheetTitle,{color:p.header.titleColor,fontFamily:b.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>Pe(false),style:B.sheetCloseButton,children:jsx(st,{size:20,color:p.header.buttonColor,strokeWidth:2})})]}),jsx(at,{style:B.sheetList,contentContainerStyle:B.sheetListContent,showsVerticalScrollIndicator:false,children:F.map(L=>jsxs(TouchableOpacity$1,{onPress:()=>{x(L.symbol),Pe(false);},activeOpacity:.7,style:[B.sheetItem,{backgroundColor:C===L.symbol?p.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:oe(Te(L,"png"))},style:B.sheetItemIcon}),jsxs(View,{style:B.sheetItemText,children:[jsx(Text,{style:[B.sheetItemTitle,{color:p.card.titleColor,fontFamily:b.medium}],children:L.symbol}),jsxs(Text,{style:[B.sheetItemSubtitle,{color:p.card.subtitleColor,fontFamily:b.regular}],children:[L.chains.length," network",L.chains.length!==1?"s":""," available"]})]}),C===L.symbol&&jsx(Le,{size:20,color:S.primary,strokeWidth:2})]},L.symbol))})]}),Q=()=>jsxs(bt,{visible:$e,onClose:()=>ue(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.chainSelector?.borderTopLeftRadius??m,borderTopRightRadius:h?.chainSelector?.borderTopRightRadius??g,children:[jsxs(View,{style:[B.sheetHeader,{borderBottomColor:S.border}],children:[jsx(View,{style:B.sheetHeaderSpacer}),jsx(Text,{style:[B.sheetTitle,{color:p.header.titleColor,fontFamily:b.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>ue(false),style:B.sheetCloseButton,children:jsx(st,{size:20,color:p.header.buttonColor,strokeWidth:2})})]}),jsx(at,{style:B.sheetList,contentContainerStyle:B.sheetListContent,showsVerticalScrollIndicator:false,children:Vt.map(L=>{let I=za(L.chain_id,L.chain_type),D=_===I;return jsxs(TouchableOpacity$1,{onPress:()=>{k(I),ue(false);},activeOpacity:.7,style:[B.sheetItem,{backgroundColor:D?p.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:oe(Te(L,"png"))},style:B.sheetItemIcon}),jsxs(View,{style:B.sheetItemText,children:[jsx(Text,{style:[B.sheetItemTitle,{color:p.card.titleColor,fontFamily:b.medium}],children:L.chain_name}),jsxs(Text,{style:[B.sheetItemSubtitle,{color:p.card.subtitleColor,fontFamily:b.regular}],children:["Min deposit: $",L.minimum_deposit_amount_usd]})]}),D&&jsx(Le,{size:20,color:S.primary,strokeWidth:2})]},I)})})]});return jsxs(View,{style:B.container,children:[jsxs(View,{style:B.selectorSection,children:[jsx(Text,{style:[B.selectorLabel,{color:p.card.labelColor,fontFamily:b.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>Pe(true),style:[B.selector,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[je&&jsx(Image,{source:{uri:oe(Te(je,"png"))},style:B.selectorIcon}),jsx(Text,{style:[B.selectorText,{color:p.card.titleColor,fontFamily:b.medium}],children:C}),jsx(Gt,{size:16,color:p.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:B.selectorSection,children:[jsxs(Text,{style:[B.selectorLabel,{color:p.card.labelColor,fontFamily:b.regular}],children:["Network"," ",jsxs(Text,{style:[B.minDeposit,{fontFamily:b.regular}],children:["($",Se," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>ue(true),style:[B.selector,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[ot&&jsx(Image,{source:{uri:oe(Te(ot,"png"))},style:B.selectorIcon}),jsx(Text,{style:[B.selectorText,{color:p.card.titleColor,fontFamily:b.medium}],numberOfLines:1,children:ot?.chain_name||"Select network"}),jsx(Gt,{size:16,color:p.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:B.qrContainer,children:jsx(View,{style:[B.qrWrapper,{backgroundColor:S.background,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth>0?p.card.borderWidth:1,borderColor:p.card.borderColor}],children:W?jsxs(View,{style:B.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:S.primary}),jsx(Text,{style:[B.loadingText,{color:S.foregroundMuted,fontFamily:b.regular}],children:"Loading..."})]}):X?jsx(Es,{value:X,size:160,logoUri:oe(Te(ot,"png")||cr("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:B.qrLoading,children:jsx(Text,{style:[B.errorText,{color:S.error,fontFamily:b.regular}],children:"No address available"})})})}),jsxs(View,{style:B.addressSection,children:[jsxs(View,{style:B.addressHeader,children:[jsx(Text,{style:[B.addressLabel,{color:p.card.labelColor,fontFamily:b.medium}],children:"Deposit Address"}),Ye&&jsxs(View,{style:B.copiedIndicator,children:[jsx(Le,{size:14,color:S.success,strokeWidth:2}),jsx(Text,{style:[B.copiedText,{color:S.success,fontFamily:b.regular}],children:"Copied"})]})]}),jsxs(Cr,{cardTokens:p.transferCrypto.depositAddress.card,onPress:!W&&X?Lt:void 0,contentStyle:B.addressBox,children:[jsx(Text,{style:[B.addressText,{color:p.card.titleColor,fontFamily:b.regular}],numberOfLines:2,children:W?"Loading...":X||"No address available"}),jsx(View,{style:B.addressCopyIcon,children:jsx(ln,{size:16,color:p.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[B.detailsCard,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>we(!ne),style:B.detailsHeader,children:[jsxs(View,{style:B.detailsRow,children:[jsx(View,{style:[B.detailIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(Nr,{size:12,color:p.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[B.detailsLabel,{color:p.card.titleColor,fontFamily:b.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:B.chevronContainer,children:ne?jsx(Vo,{size:16,color:p.card.actionColor,strokeWidth:2}):jsx(Gt,{size:16,color:p.card.actionColor,strokeWidth:2})})]}),ne&&jsxs(View,{style:B.detailsContent,children:[jsxs(View,{style:B.detailsRow,children:[jsx(View,{style:[B.detailIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(An,{size:12,color:p.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[B.detailsLabel,{color:p.card.titleColor,fontFamily:b.regular}],children:["Price impact: ",Bt.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Ae(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(es,{size:14,color:p.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:B.detailsRow,children:[jsx(View,{style:[B.detailIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(jr,{size:12,color:p.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[B.detailsLabel,{color:p.card.titleColor,fontFamily:b.regular}],children:["Slippage: Auto \u2022 ",yt.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Ae(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(es,{size:14,color:p.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:B.detailsRow,children:[jsx(View,{style:[B.detailIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(il,{size:12,color:p.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[B.detailsLabel,{color:p.card.titleColor,fontFamily:b.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(ac,{depositConfirmationMode:c,depositAddress:X,showWaitingUi:It,latestExecution:ie,onIveDeposited:me}),jsx(TouchableOpacity$1,{style:B.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[B.termsText,{color:S.primary,fontFamily:b.regular}],children:"Terms apply"})}),Z(),Q(),jsxs(bt,{visible:et,onClose:()=>Ae(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:h?.infoSheet?.borderTopLeftRadius??m,borderTopRightRadius:h?.infoSheet?.borderTopRightRadius??g,children:[jsxs(View,{style:[B.sheetHeader,{borderBottomColor:S.border}],children:[jsx(View,{style:B.sheetHeaderSpacer}),jsx(Text,{style:[B.sheetTitle,{color:p.header.titleColor,fontFamily:b.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>Ae(false),style:B.sheetCloseButton,children:jsx(st,{size:20,color:p.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:B.infoSheetContent,children:[jsxs(View,{style:[B.infoCard,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[jsxs(View,{style:B.infoCardHeader,children:[jsx(View,{style:[B.infoCardIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(An,{size:16,color:p.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[B.infoCardTitle,{color:p.card.titleColor,fontFamily:b.medium}],children:"Price Impact"}),jsxs(Text,{style:[B.infoCardValue,{color:p.card.titleColor,fontFamily:b.medium}],children:[Bt.toFixed(2),"%"]})]}),jsx(Text,{style:[B.infoCardDescription,{color:p.card.descriptionColor,fontFamily:b.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[B.infoCard,{backgroundColor:p.card.backgroundColor,borderRadius:p.card.borderRadius,borderWidth:p.card.borderWidth,borderColor:p.card.borderColor}],children:[jsxs(View,{style:B.infoCardHeader,children:[jsx(View,{style:[B.infoCardIcon,{backgroundColor:p.card.iconBackgroundColor,borderRadius:p.card.iconContainerBorderRadius}],children:jsx(jr,{size:16,color:p.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[B.infoCardTitle,{color:p.card.titleColor,fontFamily:b.medium}],children:"Max Slippage"}),jsxs(Text,{style:[B.infoCardValue,{color:p.card.titleColor,fontFamily:b.medium}],children:[yt.toFixed(2),"%"]})]}),jsx(Text,{style:[B.infoCardDescription,{color:p.card.descriptionColor,fontFamily:b.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),ie&&jsx(Ms,{visible:ze,status:ie.status,tokenIconUrl:ie.destination_token_metadata?.icon_urls?.find(L=>L.format==="png")?.url||ie.destination_token_metadata?.icon_url||Te(je,"png"),explorerUrl:ie.explorer_url,completionExplorerUrl:ie.destination_explorer_url,date:ie.created_at?new Date(ie.created_at):void 0,amountUsd:ie.source_amount_usd?parseFloat(ie.source_amount_usd):void 0,onClose:()=>it(false),borderTopLeftRadius:h?.depositStatus?.borderTopLeftRadius??m,borderTopRightRadius:h?.depositStatus?.borderTopRightRadius??g})]})}var B=StyleSheet.create({container:{flex:1,padding:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:13,marginBottom:8},minDeposit:{fontSize:10},selector:{flexDirection:"row",alignItems:"center",gap:10,padding:12,borderRadius:12},selectorIcon:{width:24,height:24,borderRadius:12},selectorText:{flex:1,fontSize:14,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:16},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:13},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},spacer:{flex:1},termsContainer:{alignItems:"center"},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},sheetList:{flex:1,paddingTop:8},sheetListContent:{paddingBottom:56},sheetItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:16,marginHorizontal:8,borderRadius:12,gap:12},sheetItemIcon:{width:40,height:40,borderRadius:20},sheetItemText:{flex:1},sheetItemTitle:{fontSize:16,fontWeight:"500"},sheetItemSubtitle:{fontSize:12,marginTop:2},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});function dc({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:i}=V();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[Ui.container,{backgroundColor:i.card.backgroundColor,borderRadius:i.list.rowBorderRadius,borderWidth:i.card.borderWidth,borderColor:i.card.borderColor}],children:[jsxs(View,{style:Ui.leftContent,children:[jsx(View,{style:[Ui.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:oe(Te(e,"png"))},style:Ui.icon})}),jsxs(View,{style:Ui.textContainer,children:[jsx(Text,{style:[Ui.name,{color:i.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[Ui.code,{color:i.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(Le,{size:16,color:o.primary,strokeWidth:2})]})}var Ui=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,marginHorizontal:8,marginVertical:4},leftContent:{flexDirection:"row",alignItems:"center",gap:12},iconContainer:{width:40,height:40,borderRadius:20,overflow:"hidden",alignItems:"center",justifyContent:"center"},icon:{width:40,height:40,borderRadius:20},textContainer:{gap:2},name:{fontSize:14,fontWeight:"400"},code:{fontSize:12,fontWeight:"300"}});function Ha({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:i}=V();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:xf.headerContainer,children:jsx(Text,{style:[xf.title,{color:i.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(s=>jsx(dc,{currency:s,isSelected:r.toLowerCase()===s.currency_code.toLowerCase(),onSelect:o},s.currency_code))]})}var xf=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function pc({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:i,borderTopLeftRadius:s,borderTopRightRadius:a}){let{colors:l,fonts:u,components:c}=V(),[y,T]=useState(""),w=o.map(d=>r.find(C=>C.currency_code.toLowerCase()===d.toLowerCase())).filter(d=>d!==void 0),m=r.filter(d=>!o.includes(d.currency_code.toLowerCase())),g=d=>{if(!y)return d;let C=y.toLowerCase();return d.filter(x=>x.name.toLowerCase().includes(C)||x.currency_code.toLowerCase().includes(C))},h=g(w),S=g(m),b=d=>{i(d),t(false),T("");},p=()=>{t(false),T("");};return jsxs(bt,{visible:e,onClose:p,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:s,borderTopRightRadius:a,children:[jsx(Ur,{title:"Currency",showBack:false,onClose:p}),jsx(View,{style:Hi.searchContainer,children:jsx(TextInput,{style:[Hi.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:u.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],value:y,onChangeText:T,placeholder:"Search",placeholderTextColor:c.search.placeholderColor})}),jsx(at,{style:Hi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:Hi.listContent,children:[jsx(Ha,{title:"Popular currencies",currencies:h,selectedCurrency:n,onSelect:b}),h.length>0&&S.length>0&&jsx(View,{style:Hi.sectionSpacer}),jsx(Ha,{title:"All currencies",currencies:S,selectedCurrency:n,onSelect:b}),h.length===0&&S.length===0&&jsx(View,{style:Hi.noResultsContainer,children:jsx(Text,{style:[Hi.noResultsText,{color:c.container.subtitleColor,fontFamily:u.regular}],children:"No currencies found"})})]})})]})}var Hi=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:18,paddingBottom:12},searchInput:{padding:16,fontSize:14},listContainer:{flex:1,paddingHorizontal:12},listContent:{paddingBottom:72},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});function vu(e){try{return new Intl.NumberFormat("en",{style:"currency",currency:e.toUpperCase(),minimumFractionDigits:0,maximumFractionDigits:0}).format(0).replace(/\d/g,"").trim()}catch{return e.toUpperCase()}}function hc({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:i,destinationChainType:s,destinationChainId:a,destinationTokenAddress:l,onDepositSuccess:u,onDepositError:c,borderTopLeftRadius:y,borderTopRightRadius:T,sheetBorderRadius:w}){let{colors:m,fonts:g,components:h}=V(),[S,b]=useState(""),[p,d]=useState("usd"),[C,x]=useState(false),[_,k]=useState(false),[v,M]=useState([]),[W,O]=useState(false),[F,U]=useState(null),[j,le]=useState(null),[Ye,_e]=useState("amount"),[ne,we]=useState(null),[fe,Pe]=useState(true),[$e,ue]=useState(null),[J,be]=useState(false),vt=useRef(null),ve=useRef(false);useEffect(()=>{vt.current=ne;},[ne]),useEffect(()=>{ve.current=J;},[J]);let[qe,Ne]=useState([]),[Ve,ze]=useState(true),[it,ie]=useState(60),[pe,et]=useState([]),[Ae,Ke]=useState([]),[$t,Ee]=useState(null),[Oe,ar]=useState(null),[he,X]=useState(true),[Ce,pt]=useState(null),[It,me]=useState(false),[je,Vt]=useState(null),[ot,Lt]=useState(false),[Bt,yt]=useState(false),[Se,Z]=useState(false),[Q,L]=useState(null),I=r??Ye,D=useRef(null),q=pe.find(Y=>Y.currency_code.toLowerCase()===p.toLowerCase()),Fe=useCallback(Y=>{_e(Y),Y==="quotes"?o?.(Y,v.length):o?.(Y);},[v.length,o]);useEffect(()=>{async function Y(){try{let ae=await ca();ar(ae);}catch(ae){console.error("Error fetching user IP:",ae);}finally{X(false);}}Y();},[]),useEffect(()=>{async function Y(){try{let ae=await dn({external_user_id:e,recipient_address:i,destination_chain_type:s,destination_chain_id:a,destination_token_address:l},t);Ne(ae.data);}catch(ae){console.error("Error fetching wallets:",ae),U("Failed to load wallet addresses");}finally{ze(false);}}Y();},[e,i,s,a,l,t]);let ke=n||$t?.symbol.toUpperCase()||"USDC",pr=os($t?.icon_urls,"png")||$t?.icon_url,ce=os($t?.chain_icon_urls,"png")||$t?.chain_icon_url;useEffect(()=>{async function Y(){try{let ae=await aa(t);et(ae.data),Ke(ae.preferred||[]);}catch(ae){console.error("Error fetching fiat currencies:",ae);}}Y();},[t]),useEffect(()=>{if(C||pe.length===0||!Oe?.alpha2)return;let Y=Oe.alpha2.toUpperCase(),ae=pe.find(qt=>qt.country_codes.includes(Y));if(ae)d(ae.currency_code.toLowerCase()),!S&&!_&&b(String(ae.default_amount??100));else if(!S&&!_){let qt=pe.find(Tr=>Tr.currency_code.toLowerCase()==="usd");qt&&b(String(qt.default_amount??100));}},[pe,Oe,C,S,_]),useEffect(()=>{if(pe.length!==0){if(D.current!==null&&D.current!==p){let Y=pe.find(ae=>ae.currency_code.toLowerCase()===p.toLowerCase());Y&&b(String(Y.default_amount??100));}D.current=p;}},[p,pe]),useEffect(()=>{async function Y(){try{let ae=await rd({chain_type:s||"",chain_id:a||"",token_address:l||""},t);Ee(ae);}catch(ae){console.error("Error fetching supported tokens:",ae);}}Y();},[s,a,l,t]),useEffect(()=>{async function Y(){if(!(!l||!a||!s)&&!he){me(true);try{let ae=await id({country_code:Oe?.alpha2?.toUpperCase()||"US",subdivision_code:Oe?.state||void 0,token_address:l,chain_id:a,chain_type:s},t);pt(ae);}catch(ae){console.error("Error fetching default onramp token:",ae);}finally{me(false);}}}Y();},[l,a,s,Oe,he,t]),useEffect(()=>{let Y=parseFloat(S);if(isNaN(Y)||Y<=0){M([]),le(null);return}if(!Ce||It){M([]),we(null);return}let ae=pe.find(Tr=>Tr.currency_code.toLowerCase()===p.toLowerCase());if(ae){if(Y<ae.minimum_amount){M([]),we(null),le(`Minimum amount is ${vu(p)}${ae.minimum_amount.toLocaleString()}`);return}if(Y>ae.maximum_amount){M([]),we(null),le(`Maximum amount is ${vu(p)}${ae.maximum_amount.toLocaleString()}`);return}}le(null);let qt=setTimeout(()=>{xt(Y);},500);return ()=>clearTimeout(qt)},[S,p,t,Ce,It,pe]);let xt=async Y=>{if(!Ce){U("Loading token information...");return}O(true),U(null);try{let ae={country_code:Oe?.alpha2?.toUpperCase()||"US",source_amount:Y.toString(),source_currency:p.toLowerCase(),destination_currency:Ce.destination_currency,destination_network:Ce.destination_network,subdivision_code:Oe?.state||void 0},qt=await od(ae,t);M(qt.data);let Tr=ve.current,an=vt.current;if(Tr&&an){let Bn=qt.data.find(Wn=>Wn.service_provider===an.service_provider);if(Bn){if(we(Bn),qt.data.length>0){let Wn=qt.data[0];$e||ue(Wn.service_provider),Pe(Bn.service_provider===$e);}}else if(qt.data.length>0){let Wn=qt.data[0];we(Wn),ue(Wn.service_provider),Pe(!0),be(!1);}}else if(qt.data.length>0){let Bn=qt.data[0];we(Bn),ue(Bn.service_provider),Pe(!0);}ie(60);}catch(ae){console.error("Failed to fetch quotes:",ae),U("Failed to fetch quotes. Please try again."),M([]);}finally{O(false);}};useEffect(()=>{if(v.length===0)return;let Y=setInterval(()=>{ie(ae=>{if(ae<=1){let qt=parseFloat(S);return !isNaN(qt)&&qt>0&&xt(qt),60}return ae-1});},1e3);return ()=>clearInterval(Y)},[v.length,S]);let Ct=Y=>{(/^\d*\.?\d{0,2}$/.test(Y)||Y==="")&&(b(Y),k(true));},z=Y=>{b(Y.toString()),k(true);},Xr=async()=>{if(ne&&Ce)try{let Y=Ce.destination_token_metadata.chain_type,ae=un(qe,Y);if(!ae?.address){U("Wallet address not available");return}let qt={service_provider:ne.service_provider,country_code:ne.country_code?.toUpperCase()||Oe?.alpha2?.toUpperCase()||"US",source_currency:ne.source_currency,source_amount:S,destination_currency:ne.destination_currency,destination_network:ne.destination_network,wallet_address:ae.address,subdivision_code:Oe?.state||void 0},Tr=await nd(qt,t);Vt({provider:ne,sourceCurrency:p,sourceAmount:S,sessionUrl:Tr.url}),L(Tr.url),Z(!0);}catch(Y){console.error("Failed to create session:",Y),U("Failed to start payment flow"),c?.({message:"Failed to start payment flow",error:Y});}},dt=vu(p),Ga=()=>{Z(false),Fe("onramp"),u?.({message:"Payment flow completed"});},Yi=()=>jsx(Ab,{visible:Se,onClose:Ga,url:Q,providerName:ne?.service_provider_display_name||"Complete Payment",colors:m,fonts:g,borderTopLeftRadius:w?.webView?.borderTopLeftRadius??y,borderTopRightRadius:w?.webView?.borderTopRightRadius??T});return I==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:K.amountViewContainer,children:[jsxs(at,{style:K.scrollContainer,contentContainerStyle:K.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:K.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>Lt(true),style:[K.currencyButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.input.borderRadius,borderWidth:h.input.borderWidth,borderColor:h.input.borderColor}],children:[q&&jsx(Image,{source:{uri:oe(Te(q,"png"))},style:K.currencyIcon}),jsx(Text,{style:[K.currencyText,{color:h.card.titleColor,fontFamily:g.medium}],children:p.toUpperCase()}),jsx(Gt,{size:16,color:h.card.actionColor,strokeWidth:2})]})}),jsx(pc,{open:ot,onOpenChange:Lt,currencies:pe,preferredCurrencyCodes:Ae,selectedCurrency:p,onSelectCurrency:Y=>{d(Y.toLowerCase()),x(true);},borderTopLeftRadius:w?.currencyModal?.borderTopLeftRadius??y,borderTopRightRadius:w?.currencyModal?.borderTopRightRadius??T}),jsx(View,{style:K.amountContainer,children:jsxs(View,{style:K.amountInputRow,children:[jsx(Text,{style:[K.currencySymbol,{color:h.container.titleColor,fontFamily:g.medium}],children:dt}),jsx(TextInput,{style:[K.amountInput,{color:h.container.titleColor,fontFamily:g.medium}],value:S,onChangeText:Ct,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:m.foregroundMuted})]})}),q?.suggested_amounts&&q.suggested_amounts.length>0&&jsx(View,{style:K.quickAmounts,children:q.suggested_amounts.map(Y=>jsx(TouchableOpacity$1,{onPress:()=>z(Y),style:[K.quickAmountButton,{backgroundColor:h.card.backgroundColor,borderRadius:h.button.borderRadius,borderWidth:parseFloat(S)===Y?2:h.button.borderWidth,borderColor:parseFloat(S)===Y?m.primary:h.button.borderColor}],children:jsxs(Text,{style:[K.quickAmountText,{color:h.card.titleColor,fontFamily:g.medium}],children:[dt,Y.toLocaleString()]})},Y))}),j&&jsx(Text,{style:[K.validationError,{color:m.error,fontFamily:g.regular}],children:j}),jsxs(View,{style:K.providerSection,children:[jsxs(View,{style:K.providerHeader,children:[jsx(Text,{style:[K.providerLabel,{color:h.card.labelColor,fontFamily:g.medium}],children:"Provider"}),v.length>0&&!W&&jsxs(Text,{style:[K.refreshText,{color:h.card.labelRightColor,fontFamily:g.regular}],children:["Refreshing in ",it,"s"]})]}),jsx(Cr,{cardTokens:h.depositCard.quoteProvider.card,onPress:W||v.length===0?void 0:()=>yt(true),contentStyle:StyleSheet.flatten([K.providerButton,(W||v.length===0)&&K.disabled]),children:W?jsxs(View,{style:K.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:m.primary}),jsx(Text,{style:[K.loadingText,{color:h.container.subtitleColor,fontFamily:g.regular}],children:"Finding best rates..."})]}):ne?jsxs(View,{style:K.providerContent,children:[jsxs(View,{style:K.providerInfo,children:[fe&&jsx(Text,{style:[K.autoPickedText,{color:h.container.subtitleColor,fontFamily:g.regular}],children:"Auto-picked for you"}),jsxs(View,{style:K.providerRow,children:[jsx(Image,{source:{uri:oe(pl(ne.icon_urls,"png",ne.icon_url))},style:K.providerIconImage},`provider-${ne.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[K.providerName,{color:h.card.titleColor,fontFamily:g.medium}],children:ne.service_provider_display_name}),jsxs(Text,{style:[K.bestPriceText,{color:h.container.subtitleColor,fontFamily:g.regular}],children:[ne.destination_amount.toFixed(2)," ",ke]})]})]})]}),jsx(_r,{size:20,color:h.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[K.noProviderText,{color:h.container.subtitleColor,fontFamily:g.regular}],children:parseFloat(S)>0?"No providers available":"Enter an amount to see providers"})}),F&&jsx(Text,{style:[K.errorText,{color:m.error,fontFamily:g.regular}],children:F})]}),jsxs(bt,{visible:Bt,onClose:()=>yt(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:w?.providerModal?.borderTopLeftRadius??y,borderTopRightRadius:w?.providerModal?.borderTopRightRadius??T,children:[jsx(Ur,{title:"Select Provider",showBack:false,onClose:()=>yt(false)}),jsx(at,{style:K.providerModalList,contentContainerStyle:K.providerModalListContent,showsVerticalScrollIndicator:false,children:jsx(View,{style:K.quotesList,children:v.map(Y=>{let ae=ne?.service_provider===Y.service_provider;return jsxs(Cr,{cardTokens:h.depositCard.quoteProvider.card,onPress:()=>{we(Y),be(true),Pe(Y.service_provider===$e),yt(false);},contentStyle:StyleSheet.flatten([K.quoteItem,ae&&{borderWidth:2,borderColor:m.primary}]),children:[jsxs(View,{style:K.quoteLeft,children:[jsx(Image,{source:{uri:oe(pl(Y.icon_urls,"png",Y.icon_url))},style:K.providerIconImage}),jsx(View,{children:jsx(Text,{style:[K.quoteName,{color:h.card.titleColor,fontFamily:g.medium}],children:Y.service_provider_display_name})})]}),jsxs(View,{style:K.quoteRight,children:[jsxs(Text,{style:[K.quoteAmount,{color:h.card.textRightColor,fontFamily:g.medium}],children:[Y.destination_amount.toFixed(2)," ",ke]}),jsxs(Text,{style:[K.quoteSource,{color:h.card.subtextRightColor,fontFamily:g.regular}],children:["Fee: ",dt,Y.total_fee.toFixed(2)]})]})]},Y.service_provider)})})})]})]}),jsx(View,{style:[K.continueButtonContainer,{backgroundColor:m.background}],children:jsx(View,{style:{opacity:W||Ve||!ne||parseFloat(S)<=0?.5:1},children:jsx(TouchableOpacity$1,{onPress:Xr,disabled:W||Ve||!ne||parseFloat(S)<=0,style:[K.continueButton,{backgroundColor:h.container.buttonColor,borderRadius:h.button.borderRadius,borderWidth:h.button.borderWidth,borderColor:h.button.borderColor}],children:jsx(Text,{style:[K.continueButtonText,{color:h.container.buttonTitleColor,fontFamily:g.medium}],children:Ve?"Loading...":"Continue"})})})})]}),Yi()]}):I==="onramp"&&je?jsxs(View,{style:K.onrampContainer,children:[jsx(Image,{source:{uri:oe(pl(je.provider.icon_urls,"png",je.provider.icon_url))},style:K.onrampProviderIcon}),jsxs(Text,{style:[K.onrampTitle,{color:h.container.titleColor,fontFamily:g.medium}],children:["Complete transaction with ",je.provider.service_provider_display_name]}),jsx(Text,{style:[K.onrampSubtitle,{color:h.container.subtitleColor,fontFamily:g.regular}],children:"You can close this modal."}),jsxs(View,{style:[K.flowDiagram,{backgroundColor:h.card.backgroundColor}],children:[jsxs(View,{style:K.flowStep,children:[jsx(Image,{source:{uri:cr(`/icons/currencies/png/${je.sourceCurrency.toLowerCase()}.png`)},style:K.flowIconImage}),jsx(Text,{style:[K.flowLabel,{color:h.card.subtitleColor,fontFamily:g.regular}],children:"You use"}),jsx(Text,{style:[K.flowValue,{color:h.card.titleColor,fontFamily:g.medium}],children:je.sourceCurrency.toUpperCase()})]}),jsx(_r,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:K.flowStep,children:[jsxs(View,{style:K.flowIconWithBadge,children:[jsx(Image,{source:{uri:os(Ce?.destination_token_metadata?.icon_urls,"png")||Ce?.destination_token_metadata?.icon_url||cr("/icons/tokens/png/usdc.png")},style:K.flowIconImageNoBadge}),jsx(Image,{source:{uri:os(Ce?.destination_token_metadata?.chain?.icon_urls,"png")||Ce?.destination_token_metadata?.chain?.icon_url||cr("/icons/networks/png/polygon.png")},style:[K.flowNetworkBadge,{borderColor:m.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[K.flowLabel,{color:h.card.subtitleColor,fontFamily:g.regular}],children:"You buy"}),jsx(Text,{style:[K.flowValue,{color:h.card.titleColor,fontFamily:g.medium}],children:"USDC"})]}),jsx(_r,{size:16,color:h.card.actionColor,strokeWidth:2}),jsxs(View,{style:K.flowStep,children:[jsxs(View,{style:K.flowIconWithBadge,children:[jsx(Image,{source:{uri:pr||cr("/icons/tokens/png/usdc.png")},style:K.flowIconImageNoBadge}),jsx(Image,{source:{uri:ce||cr("/icons/networks/png/polygon.png")},style:[K.flowNetworkBadge,{borderColor:m.background,borderRadius:h.badge.borderRadius}]})]}),jsx(Text,{style:[K.flowLabel,{color:h.card.subtitleColor,fontFamily:g.regular}],children:"You receive"}),jsx(Text,{style:[K.flowValue,{color:h.card.titleColor,fontFamily:g.medium}],children:ke})]})]}),jsx(View,{style:[K.onrampInfoBox,{backgroundColor:h.card.backgroundColor,borderRadius:h.card.borderRadius,borderWidth:h.card.borderWidth,borderColor:h.card.borderColor}],children:jsx(Text,{style:[K.onrampInfoText,{color:h.card.descriptionColor,fontFamily:g.regular}],children:"The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."})})]}):null}function Ab({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:i,borderTopLeftRadius:s,borderTopRightRadius:a}){return jsxs(bt,{visible:e,onClose:t,closeOnBackdropPress:false,enablePanDownToClose:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:s,borderTopRightRadius:a,children:[jsxs(View,{style:Ni.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:Ni.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Le,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[Ni.headerTitle,{color:n.foreground,fontFamily:i.medium}],children:o}),jsx(View,{style:Ni.headerSpacer})]}),r&&jsx(View,{style:Ni.container,children:jsx(WebView,{source:{uri:r},style:Ni.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:Ni.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var Ni=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},headerButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},headerSpacer:{width:28,height:28},container:{flex:1},webView:{flex:1},loading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"}}),K=StyleSheet.create({amountViewContainer:{flex:1},scrollContainer:{flex:1},scrollContent:{padding:16,paddingBottom:16},currencySelector:{alignItems:"center",marginBottom:16},currencyButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8},currencyText:{fontSize:14,fontWeight:"500"},currencyIcon:{width:24,height:24,borderRadius:12},amountContainer:{alignItems:"center",marginBottom:24},amountInputRow:{flexDirection:"row",alignItems:"center",marginBottom:8},currencySymbol:{fontSize:48,fontWeight:"300"},amountInput:{fontSize:48,fontWeight:"300",minWidth:50},usdcPreview:{fontSize:14},quickAmounts:{flexDirection:"row",justifyContent:"center",gap:12,marginBottom:24},quickAmountButton:{paddingHorizontal:20,paddingVertical:10},quickAmountText:{fontSize:14,fontWeight:"500"},validationError:{fontSize:12,textAlign:"center",marginTop:12,paddingHorizontal:16},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16},disabled:{opacity:.5},providerLoading:{flexDirection:"row",alignItems:"center",gap:12},loadingText:{fontSize:14},providerContent:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},providerInfo:{flex:1},autoPickedText:{fontSize:12,marginBottom:6},providerRow:{flexDirection:"row",alignItems:"center",gap:12},providerIcon:{width:32,height:32,borderRadius:16},providerIconPlaceholder:{width:32,height:32,borderRadius:8},providerIconImage:{width:32,height:32,borderRadius:8},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:48},continueButton:{paddingVertical:16,alignItems:"center"},continueButtonText:{fontSize:16,fontWeight:"600"},webViewHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:16,paddingTop:16,paddingBottom:8},webViewHeaderButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},webViewHeaderTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},webViewHeaderSpacer:{width:28,height:28},webViewContainer:{flex:1},webView:{flex:1},webViewLoading:{position:"absolute",top:0,left:0,right:0,bottom:0,alignItems:"center",justifyContent:"center"},providerModalList:{flex:1,paddingHorizontal:12,marginTop:8},providerModalListContent:{paddingBottom:72},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12},quoteLeft:{flexDirection:"row",alignItems:"center",gap:12},quoteIcon:{width:40,height:40,borderRadius:20},quoteName:{fontSize:14,fontWeight:"500"},quoteRight:{alignItems:"flex-end"},quoteAmount:{fontSize:14,fontWeight:"500"},quoteSource:{fontSize:12},onrampContainer:{flex:1,padding:16,alignItems:"center",paddingTop:24},onrampProviderIcon:{width:64,height:64,borderRadius:16},onrampTitle:{fontSize:18,fontWeight:"600",textAlign:"center",marginTop:20,marginBottom:8,paddingHorizontal:16},onrampSubtitle:{fontSize:14,textAlign:"center",marginBottom:24},flowDiagram:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:20,paddingHorizontal:24,borderRadius:12,width:"100%"},flowIconWithBadge:{position:"relative",width:24,height:24,marginBottom:4},flowIconImageNoBadge:{width:24,height:24,borderRadius:12},flowNetworkBadge:{position:"absolute",bottom:-4,right:-6,width:14,height:14,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,width:"100%"},onrampInfoText:{fontSize:13,lineHeight:20},flowStep:{alignItems:"center"},flowIcon:{width:28,height:28,borderRadius:14,marginBottom:4},flowIconImage:{width:24,height:24,borderRadius:12,marginBottom:4},flowLabel:{fontSize:10},flowValue:{fontSize:14,fontWeight:"500"}});function Ub(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function Hb(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function bc({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=V(),i=n.depositTracker.executionRow.card,s=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=oe(Te(e.destination_token_metadata,"png")||cr("/icons/tokens/png/usdc.png")),u=s?"Deposit Processing":"Deposit Completed",c=Ub(e.created_at||new Date().toISOString()),y=Hb(e.source_amount_usd);return jsxs(Cr,{cardTokens:i,onPress:t,contentStyle:vn.container,children:[jsxs(View,{style:vn.iconContainer,children:[jsx(Image,{source:{uri:l},style:vn.tokenIcon}),jsx(View,{style:[vn.statusBadge,{backgroundColor:s?r.warning:r.success,borderColor:i.backgroundColor}],children:s?jsx(Xi,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(Le,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:vn.textContainer,children:[jsx(Text,{style:[vn.title,{color:i.titleColor,fontFamily:o.medium}],children:u}),jsx(Text,{style:[vn.dateTime,{color:i.subtitleColor,fontFamily:o.regular}],children:c})]}),jsxs(View,{style:vn.rightContainer,children:[jsx(Text,{style:[vn.amount,{color:i.textRightColor,fontFamily:o.medium}],children:y}),jsx(_r,{size:20,color:i.actionColor,strokeWidth:2})]})]})}var vn=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16,fontWeight:"500"},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16,fontWeight:"500"}});function If(e,t){let r={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||r[e]||e:r[e]||e}function Pf(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function jb(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var Of=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function Ff(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function $b(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function qb({count:e=4}){let{colors:t,components:r}=V(),o=useRef(new Animated.Value(.5)).current,n=r.depositTracker.executionRow.card,i=t.cardHover;return useEffect(()=>{let s=Animated.loop(Animated.sequence([Animated.timing(o,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(o,{toValue:.5,duration:800,useNativeDriver:true})]));return s.start(),()=>s.stop()},[o]),jsx(View,{style:ji.list,children:Array.from({length:e}).map((s,a)=>jsxs(View,{style:[ji.row,{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius??12,borderWidth:n.borderWidth,borderColor:n.borderColor}],children:[jsx(Animated.View,{style:[ji.icon,{backgroundColor:i,opacity:o}]}),jsxs(View,{style:ji.textBlock,children:[jsx(Animated.View,{style:[ji.titleBar,{backgroundColor:i,opacity:o}]}),jsx(Animated.View,{style:[ji.subtitleBar,{backgroundColor:i,opacity:o}]})]}),jsx(Animated.View,{style:[ji.amountBar,{backgroundColor:i,opacity:o}]})]},a))})}var ji=StyleSheet.create({list:{paddingTop:16,paddingHorizontal:16,gap:12},row:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},icon:{width:40,height:40,borderRadius:20,marginRight:12},textBlock:{flex:1,gap:6},titleBar:{height:14,width:"65%",borderRadius:7},subtitleBar:{height:11,width:"45%",borderRadius:5.5},amountBar:{height:14,width:50,borderRadius:7,marginLeft:12}});function Ou({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{colors:i,fonts:s,components:a}=V(),[l,u]=useState(r),[c,y]=useState(false),[T,w]=useState(null),[m,g]=useState(false),h=useRef(null);useEffect(()=>{if(!e||!o)return;let _=async()=>{y(true);try{let M=[...(await pn(o,n)).data].sort((W,O)=>{let F=W.created_at?new Date(W.created_at).getTime():0;return (O.created_at?new Date(O.created_at).getTime():0)-F});u(M);}catch(v){console.error("Failed to fetch executions:",v),u(r);}finally{y(false);}};_();let k=setInterval(_,1e4);return ()=>clearInterval(k)},[e,o,n,r]),useEffect(()=>{r.length>0&&u(_=>{let k=new Set(_.map(M=>M.id)),v=r.filter(M=>!k.has(M.id));return v.length>0?[...v,..._]:_});},[r]),useEffect(()=>{e||w(null);},[e]);let S=_=>{w(_);},b=()=>{w(null),g(false);},p=()=>{w(null),t();},d=()=>{if(!T)return null;let _=T,k=_.status==="pending"||_.status==="waiting"||_.status==="delayed",v=_.status==="succeeded",M=oe(Te(_.destination_token_metadata,"png")||cr("/icons/tokens/png/usdc.png")),W=_.provider_metadata?.details,O=W?.currencyIn,F=W?.currencyOut;O?.currency?.symbol||"USDC";F?.currency?.symbol||"USDC";let le=Pf(_.source_amount_base_unit,_.source_token_metadata?.decimals),Ye=Pf(_.destination_amount_base_unit,_.destination_token_metadata?.decimals),_e=jb(_.source_amount_usd),ne=If(_.source_chain_type,_.source_chain_id),we=If(_.destination_chain_type,_.destination_chain_id),fe=()=>{_.explorer_url&&Linking.openURL(_.explorer_url);},Pe=()=>{_.destination_explorer_url&&Linking.openURL(_.destination_explorer_url);};return jsxs(at,{ref:h,style:ge.scrollContainer,contentContainerStyle:ge.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:ge.iconSection,children:[jsxs(View,{style:ge.iconWrapper,children:[jsx(Image,{source:{uri:M},style:ge.tokenIcon}),jsx(View,{style:[ge.statusBadge,{backgroundColor:k?i.warning:i.success,borderColor:i.background}],children:k?jsx(Gt,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(Le,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:ge.statusRow,children:[jsx(View,{style:[ge.statusDot,{backgroundColor:k?i.warning:i.success}]}),jsx(Text,{style:[ge.statusText,{color:a.container.titleColor,fontFamily:s.semibold}],children:k?"Processing":"Completed"})]}),jsx(Text,{style:[ge.dateText,{color:a.container.subtitleColor,fontFamily:s.regular}],children:$b(_.created_at||new Date().toISOString())})]}),jsxs(View,{style:[ge.card,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Amount Sent"}),jsxs(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:[le," ",Ff(_.source_currency)]})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Amount Received"}),jsxs(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:[Ye," ",Ff(_.destination_currency)]})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"USD Value"}),jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:_e})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Source Network"}),jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:ne})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]}),jsxs(View,{style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Destination Network"}),jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:we})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let $e=!m;g($e),$e?setTimeout(()=>{h.current?.scrollToEnd({animated:true});},100):h.current?.scrollTo({y:0,animated:true});},style:ge.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[ge.toggleText,{color:a.container.actionTitle,fontFamily:s.regular}],children:m?"See less":"See more details"}),m?jsx(Vo,{size:14,color:a.container.actionColor,strokeWidth:2}):jsx(Gt,{size:14,color:a.container.actionColor,strokeWidth:2})]}),m&&jsxs(View,{style:[ge.card,{backgroundColor:a.card.backgroundColor,borderRadius:a.card.borderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[_.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:fe,style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Deposit Tx"}),jsxs(View,{style:ge.cardRowRight,children:[jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:Of(_.transaction_hash)}),jsx(Do,{size:14,color:a.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[ge.cardDivider,{backgroundColor:i.border}]})]}),_.destination_explorer_url&&v&&jsxs(TouchableOpacity,{onPress:Pe,style:ge.cardRow,children:[jsx(Text,{style:[ge.cardLabel,{color:a.card.rowLeftLabel,fontFamily:s.regular}],children:"Completion Tx"}),jsxs(View,{style:ge.cardRowRight,children:[jsx(Text,{style:[ge.cardValue,{color:a.card.rowRightLabel,fontFamily:s.medium}],children:Of(_.destination_transaction_hashes[0])}),jsx(Do,{size:14,color:a.card.actionIcon,strokeWidth:2})]})]})]})]})},C=c&&l.length===0;return jsxs(Fragment,{children:[jsx(Ur,{title:T?"Deposit Details":"Deposit Tracker",onClose:p,showClose:!T,showBack:!!T,onBack:b}),T?d():C?jsx(qb,{}):jsx(at,{style:ge.scrollContainer,contentContainerStyle:ge.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:ge.emptyContainer,children:[jsx(Text,{style:[ge.emptyText,{color:a.container.titleColor,fontFamily:s.medium}],children:"No deposits yet"}),jsx(Text,{style:[ge.emptySubtext,{color:a.container.subtitleColor,fontFamily:s.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:ge.executionsList,children:l.map(_=>jsx(bc,{execution:_,onPress:()=>S(_)},_.id))})})]})}var ge=StyleSheet.create({scrollContainer:{flex:1,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:40},emptyContainer:{paddingVertical:40,paddingHorizontal:16,alignItems:"center"},emptyText:{fontSize:14,marginBottom:4},emptySubtext:{fontSize:12},executionsList:{paddingTop:8,gap:12},detailsContent:{paddingHorizontal:16,paddingBottom:32},iconSection:{alignItems:"center",marginBottom:24},iconWrapper:{position:"relative",marginBottom:12},tokenIcon:{width:72,height:72,borderRadius:36},statusBadge:{position:"absolute",bottom:0,right:0,width:28,height:28,borderRadius:14,alignItems:"center",justifyContent:"center",borderWidth:3},statusRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:16,fontWeight:"600"},dateText:{fontSize:14},card:{borderRadius:12,marginBottom:12,overflow:"hidden"},cardRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:14,paddingHorizontal:16},cardRowRight:{flexDirection:"row",alignItems:"center",gap:8},cardDivider:{height:1,marginHorizontal:16},cardLabel:{fontSize:14},cardValue:{fontSize:14,fontWeight:"500"},toggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12,paddingHorizontal:4},toggleText:{fontSize:14},buttonSection:{marginTop:12,gap:10},actionButton:{flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:16,borderRadius:12},buttonIconLeft:{marginRight:12},buttonIconRight:{marginLeft:12},buttonText:{color:"#FFFFFF",fontSize:14,fontWeight:"600",flex:1,textAlign:"left"},hintText:{fontSize:12,textAlign:"center",marginTop:8}});function Na(e,t=true){let[r,o]=useState(null),[n,i]=useState(null),[s,a]=useState(false),[l,u]=useState(false),[c,y]=useState(null),[T,w]=useState(null);useEffect(()=>{!t||r||(a(true),ca().then(S=>{o(S),y(null);}).catch(S=>{y(S instanceof Error?S:new Error(String(S)));}).finally(()=>{a(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(u(true),la(e).then(S=>{i(S),w(null);}).catch(S=>{w(S instanceof Error?S:new Error(String(S)));}).finally(()=>{u(false);}));},[t,e,n]);let m=s||l,g=c||T||null,h=null;if(r&&n){let S=n.blocked_country_codes||[],b=r.alpha2.toUpperCase();h=!S.some(p=>p.toUpperCase()===b);}return {isAllowed:h,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:m,error:g}}var Vu="unifold_recent_tokens",Jb=5,Af=[{symbol:"ETH",chainType:"ethereum",chainId:"1"},{symbol:"SOL",chainType:"solana",chainId:"mainnet"},{symbol:"USDC",chainType:"solana",chainId:"mainnet"},{symbol:"POL",chainType:"ethereum",chainId:"137"},{symbol:"BNB",chainType:"ethereum",chainId:"56"},{symbol:"BTC",chainType:"bitcoin",chainId:"mainnet"}];async function Tc(){try{let e=await Fd.getItem(Vu);return e?JSON.parse(e):[]}catch{return []}}async function Zb(e){try{let r=(await Tc()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,Jb);await Fd.setItem(Vu,JSON.stringify(o));}catch{}}async function Xb(e){try{let r=(await Tc()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await Fd.setItem(Vu,JSON.stringify(r)),r}catch{return []}}function Lu({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:i,borderTopLeftRadius:s,borderTopRightRadius:a}){let{colors:l,fonts:u,components:c}=V(),[y,T]=useState(""),[w,m]=useState([]);useEffect(()=>{e&&Tc().then(m);},[e]),useEffect(()=>{e||T("");},[e]);let g=useMemo(()=>{let C=[];return r.forEach(x=>{x.chains.forEach(_=>{C.push({token:x,chain:_});});}),C},[r]),h=useMemo(()=>{let C=[],x=new Set,_=(k,v,M,W)=>{let O=`${k}-${v}:${M}`;if(x.has(O))return;let F=r.find(j=>j.symbol===k);if(!F)return;let U=F.chains.find(j=>j.chain_type===v&&j.chain_id===M);U&&(x.add(O),C.push({token:F,chain:U,isRecent:W}));};return w.forEach(k=>{_(k.symbol,k.chainType,k.chainId,true);}),Af.forEach(k=>{_(k.symbol,k.chainType,k.chainId,false);}),C},[r,w]),S=useMemo(()=>{if(!y.trim())return g;let C=y.toLowerCase();return g.filter(({token:x,chain:_})=>x.symbol.toLowerCase().includes(C)||x.name.toLowerCase().includes(C)||_.chain_name.toLowerCase().includes(C))},[g,y]),b=(C,x,_)=>Af.some(k=>k.symbol===C&&k.chainType===x&&k.chainId===_),p=async(C,x)=>{let _=`${x.chain_type}:${x.chain_id}`;if(!b(C.symbol,x.chain_type,x.chain_id)){await Zb({symbol:C.symbol,chainType:x.chain_type,chainId:x.chain_id});let k=await Tc();m(k);}T(""),i(C.symbol,_),t();},d=async(C,x)=>{let _=await Xb({symbol:C.symbol,chainType:x.chain_type,chainId:x.chain_id});m(_);};return jsxs(bt,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,startExpanded:false,borderTopLeftRadius:s,borderTopRightRadius:a,children:[jsxs(View,{style:gt.header,children:[jsx(View,{style:gt.headerSpacer}),jsx(Text,{style:[gt.headerTitle,{color:c.header.titleColor,fontFamily:u.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:gt.closeButton,children:jsx(st,{size:20,color:c.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:gt.searchContainer,children:jsx(TextInput,{style:[gt.searchInput,{backgroundColor:c.search.backgroundColor,color:c.search.inputColor,fontFamily:u.regular,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],placeholder:"Search",placeholderTextColor:c.search.placeholderColor,value:y,onChangeText:T,autoCapitalize:"none",autoCorrect:false})}),h.length>0&&!y&&jsxs(View,{style:gt.quickSelectSection,children:[jsx(Text,{style:[gt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:u.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:gt.quickSelectScroll,children:h.map(({token:C,chain:x,isRecent:_})=>{let k=`${x.chain_type}:${x.chain_id}`;C.symbol===o&&k===n;return jsxs(View,{children:[_&&jsx(TouchableOpacity$1,{onPress:()=>d(C,x),style:gt.removeButton,children:jsx(st,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>p(C,x),activeOpacity:.7,style:[gt.quickSelectItem,{backgroundColor:c.card.backgroundColor,borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor}],children:[jsxs(View,{style:gt.tokenIconContainer,children:[jsx(Image,{source:{uri:oe(Te(C,"png"))},style:gt.quickSelectIcon}),jsx(Image,{source:{uri:oe(Te(x,"png"))},style:[gt.quickSelectChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:gt.quickSelectText,children:[jsx(Text,{style:[gt.quickSelectSymbol,{color:c.card.titleColor,fontFamily:u.medium}],children:C.symbol}),jsx(Text,{style:[gt.quickSelectChain,{color:c.card.subtitleColor,fontFamily:u.regular}],children:x.chain_name})]})]})]},`quick-${C.symbol}-${k}`)})})]}),jsx(Text,{style:[gt.sectionLabel,{color:c.list.titleSectionColor,fontFamily:u.regular}],children:"All supported tokens"}),jsx(at,{style:gt.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:gt.tokenListContent,children:S.length===0?jsx(View,{style:gt.emptyState,children:jsx(Text,{style:[gt.emptyText,{color:l.foregroundMuted,fontFamily:u.regular}],children:"No tokens found"})}):S.map(({token:C,chain:x})=>{let _=`${x.chain_type}:${x.chain_id}`,k=C.symbol===o&&_===n;return jsxs(TouchableOpacity$1,{onPress:()=>p(C,x),activeOpacity:.7,style:[gt.tokenItem,{backgroundColor:k?c.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:gt.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:oe(Te(C,"png"))},style:gt.tokenIcon}),jsx(Image,{source:{uri:oe(Te(x,"png"))},style:[gt.tokenChainBadge,{borderColor:c.card.backgroundColor,borderRadius:c.badge.borderRadius}]})]}),jsxs(View,{style:gt.tokenInfo,children:[jsx(Text,{style:[gt.tokenSymbol,{color:c.card.titleColor,fontFamily:u.medium}],children:C.symbol}),jsx(Text,{style:[gt.tokenChainName,{color:c.card.subtitleColor,fontFamily:u.regular}],children:x.chain_name})]}),jsxs(Text,{style:[gt.minDeposit,{color:c.card.labelColor,fontFamily:u.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:c.card.labelHighlightRightColor,fontFamily:u.regular},children:["$",x.minimum_deposit_amount_usd]})]})]},`${C.symbol}-${_}`)})})]})}var gt=StyleSheet.create({header:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},closeButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},headerTitle:{fontSize:16,fontWeight:"500",textAlign:"center",flex:1},headerSpacer:{width:28},searchContainer:{paddingHorizontal:16,paddingBottom:12},searchInput:{height:40,paddingHorizontal:16,fontSize:14},quickSelectSection:{marginBottom:12},sectionLabel:{fontSize:12,paddingHorizontal:16,marginBottom:8},quickSelectScroll:{paddingHorizontal:16,gap:8},quickSelectItem:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:8,paddingHorizontal:12},removeButton:{position:"absolute",top:-2,right:-6,zIndex:1,padding:2},tokenIconContainer:{position:"relative"},quickSelectIcon:{width:28,height:28,borderRadius:14},quickSelectChainBadge:{position:"absolute",bottom:-2,right:-2,width:14,height:14,borderRadius:7,borderWidth:2},quickSelectText:{alignItems:"flex-start"},quickSelectSymbol:{fontSize:12,fontWeight:"500"},quickSelectChain:{fontSize:10},tokenList:{flex:1},tokenListContent:{paddingHorizontal:16,paddingBottom:72,gap:4},emptyState:{padding:32,alignItems:"center"},emptyText:{fontSize:14},tokenItem:{flexDirection:"row",alignItems:"center",gap:12,padding:12,borderRadius:12},tokenIconContainerLarge:{position:"relative"},tokenIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenInfo:{flex:1},tokenSymbol:{fontSize:14,fontWeight:"500"},tokenChainName:{fontSize:12},minDeposit:{fontSize:12}});var _c=(e,t)=>`${t}:${e}`,nC=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function Bu({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:i,destinationTokenSymbol:s,defaultChainType:a,defaultChainId:l,defaultTokenAddress:u,depositConfirmationMode:c="auto_ui",onExecutionsChange:y,onDepositSuccess:T,onDepositError:w,wallets:m,borderTopLeftRadius:g,borderTopRightRadius:h,sheetBorderRadius:S}){let{colors:b,fonts:p,components:d}=V(),C=a&&l?`${a}:${l}`:"solana:mainnet",[x,_]=useState("USDC"),[k,v]=useState(C),[M,W]=useState([]),[O,F]=useState(!m?.length),U=m?.length?m:M,[j,le]=useState([]),[Ye,_e]=useState(true),[ne,we]=useState(false),[fe,Pe]=useState(false),[$e,ue]=useState(false),[J,be]=useState([]),[vt,ve]=useState(new Map),[qe]=useState(()=>new Date),[Ne,Ve]=useState(null),[ze,it]=useState(false),[ie,pe]=useState(null),[et,Ae]=useState(false),Ke=new Map;j.forEach(Z=>{Z.chains.forEach(Q=>{let L=`${Q.chain_type}:${Q.chain_id}`;Ke.has(L)||Ke.set(L,Q);});});let $t=Array.from(Ke.values()),Ee=nC(k),Oe=$t.find(Z=>Z.chain_type===Ee.chainType&&Z.chain_id===Ee.chainId),ar=Oe?.chain_type||"ethereum",he=un(U,ar),X=he?.address||"",Ce=useRef(false);useEffect(()=>{async function Z(){try{_e(!0),Ve(null);let L=await Ci(t,i&&n&&o?{destination_token_address:i,destination_chain_id:n,destination_chain_type:o}:void 0);if(le(L.data),L.data.length>0&&!Ce.current){Ce.current=!0;let I,D;if(a&&l)if(u)for(let q of L.data){let Fe=q.chains.find(ke=>ke.chain_type===a&&ke.chain_id===l&&ke.token_address.toLowerCase()===u.toLowerCase());if(Fe){I=q,D=Fe;break}}else for(let q of L.data){let Fe=q.chains.find(ke=>ke.chain_type===a&&ke.chain_id===l);if(Fe){I=q,D=Fe;break}}if(!I&&i)for(let q of L.data){let Fe=q.chains.find(ke=>ke.token_address.toLowerCase()===i.toLowerCase());if(Fe){I=q,D=Fe;break}}I||(I=L.data.find(q=>q.symbol==="USDC"),I&&I.chains.length>0&&(D=I.chains[0])),I||(I=L.data.find(q=>q.symbol==="USDT"),I&&I.chains.length>0&&(D=I.chains[0])),I||(I=L.data[0],I.chains.length>0&&(D=I.chains[0])),I&&_(I.symbol),D&&v(_c(D.chain_id,D.chain_type));}}catch(Q){console.error("Error fetching supported tokens:",Q),Ve("Failed to load supported tokens"),w?.({message:"Failed to load supported tokens",error:Q});}finally{_e(false);}}Z();},[t,i,n,o,a,l,u,w]),useEffect(()=>{y&&y(J);},[J,y]),useEffect(()=>{if(m?.length){F(false);return}if(M.length>0){F(false);return}let Z=null,Q=false,L=async()=>{if(!Q){F(true);try{let I=await dn({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:i},t);Q||(W(I.data),Ve(null),F(!1));}catch(I){console.error("Error fetching wallets, retrying in 5s:",I),Q||(Ve(I instanceof Error?I.message:"Failed to load wallets"),F(false),Z=setTimeout(L,5e3));}}};return L(),()=>{Q=true,Z&&clearTimeout(Z);}},[e,r,o,n,i,t,m,M.length]);let pt=he?.id??"",{showWaitingUi:It,handleIveDeposited:me}=Ma({depositConfirmationMode:c,depositAddress:X,chain:k,externalUserId:e,publishableKey:t,modalOpenedAt:qe,depositWalletId:pt,depositExecutions:J,trackedExecutions:vt,setDepositExecutions:be,setTrackedExecutions:ve,setLatestExecution:pe,setShowStatusSheet:it,onDepositSuccess:T,onExecutionsChange:y,onDepositError:w});useEffect(()=>{if(!j.length)return;let Z=j.find(L=>L.symbol===x);if(!Z||Z.chains.length===0)return;if(!Z.chains.some(L=>_c(L.chain_id,L.chain_type)===k)){let L=Z.chains[0];v(_c(L.chain_id,L.chain_type));}},[x,j,k]);let je=j.find(Z=>Z.symbol===x),ot=(je?.chains||[]).find(Z=>_c(Z.chain_id,Z.chain_type)===k),Lt=async()=>{if(X)try{Clipboard.setString(X),we(!0),setTimeout(()=>we(!1),2e3);}catch(Z){console.error("Failed to copy:",Z);}},Bt=ot?.estimated_price_impact_percent??0,yt=ot?.max_slippage_percent??.25,Se=ot?.minimum_deposit_amount_usd??3;return Ye?jsxs(View,{style:N.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:b.primary}),jsx(Text,{style:[N.loadingText,{color:b.foregroundMuted,fontFamily:p.regular}],children:"Loading currencies..."})]}):Ne&&j.length===0?jsxs(View,{style:N.errorContainer,children:[jsx(Text,{style:[N.errorText,{color:b.error,fontFamily:p.regular}],children:Ne}),jsx(Text,{style:[N.errorHint,{color:b.foregroundMuted,fontFamily:p.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:N.container,children:[jsxs(View,{style:N.selectorSection,children:[jsx(Text,{style:[N.selectorLabel,{color:d.card.labelColor,fontFamily:p.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>ue(true),disabled:Ye||j.length===0,style:[N.tokenSelectorButton,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],activeOpacity:.7,children:Ye?jsxs(View,{style:N.tokenSelectorLoading,children:[jsx(View,{style:[N.loadingIcon,{backgroundColor:b.cardHover}]}),jsxs(View,{style:N.loadingTextContainer,children:[jsx(View,{style:[N.loadingLine,{backgroundColor:b.cardHover,width:60}]}),jsx(View,{style:[N.loadingLine,{backgroundColor:b.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:N.tokenIconWrapper,children:[je&&jsx(Image,{source:{uri:oe(Te(je,"png"))},style:N.tokenMainIcon}),(ot||Oe)&&jsx(Image,{source:{uri:oe(Te(ot||Oe,"png"))},style:[N.tokenChainBadge,{borderColor:d.card.backgroundColor,borderRadius:d.badge.borderRadius}]})]}),jsxs(View,{style:N.tokenSelectorInfo,children:[jsx(Text,{style:[N.tokenSelectorSymbol,{color:d.card.titleColor,fontFamily:p.semibold}],children:je?.symbol||x}),jsx(Text,{style:[N.tokenSelectorNetwork,{color:d.card.subtitleColor,fontFamily:p.regular}],numberOfLines:1,children:ot?.chain_name||Oe?.chain_name||"Select network"})]}),jsxs(View,{style:N.tokenSelectorRight,children:[jsxs(Text,{style:[N.minDepositText,{color:d.card.labelHighlightRightColor,fontFamily:p.medium}],children:["$",Se," min"]}),jsx(_r,{size:16,color:d.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Lu,{visible:$e,onClose:()=>ue(false),tokens:j,selectedToken:x,selectedChainKey:k,onSelect:(Z,Q)=>{_(Z),v(Q);},borderTopLeftRadius:S?.tokenSelector?.borderTopLeftRadius??g,borderTopRightRadius:S?.tokenSelector?.borderTopRightRadius??h}),jsx(View,{style:N.qrContainer,children:jsx(View,{style:[N.qrWrapper,{backgroundColor:b.background,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth>0?d.card.borderWidth:1,borderColor:d.card.borderColor}],children:O?jsxs(View,{style:N.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:b.primary}),jsx(Text,{style:[N.loadingText,{color:b.foregroundMuted,fontFamily:p.regular}],children:"Loading..."})]}):X?jsx(Es,{value:X,size:180,logoUri:oe(Te(ot,"png")||cr("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:N.qrLoading,children:jsx(Text,{style:[N.errorText,{color:b.error,fontFamily:p.regular}],children:"No address available"})})})}),jsxs(View,{style:N.addressSection,children:[jsxs(View,{style:N.addressHeader,children:[jsx(Text,{style:[N.addressLabel,{color:d.card.labelColor,fontFamily:p.medium}],children:"Deposit Address"}),ne&&jsxs(View,{style:N.copiedIndicator,children:[jsx(Le,{size:14,color:b.success,strokeWidth:2}),jsx(Text,{style:[N.copiedText,{color:b.success,fontFamily:p.regular}],children:"Copied"})]})]}),jsxs(Cr,{cardTokens:d.transferCrypto.depositAddress.card,onPress:!O&&X?Lt:void 0,contentStyle:N.addressBox,children:[jsx(Text,{style:[N.addressText,{color:d.card.titleColor,fontFamily:p.regular}],numberOfLines:2,children:O?"Loading...":X||"No address available"}),jsx(View,{style:N.addressCopyIcon,children:jsx(ln,{size:16,color:d.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[N.detailsCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Pe(!fe),style:N.detailsHeader,children:[jsxs(View,{style:N.detailsRow,children:[jsx(View,{style:[N.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(Nr,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[N.detailsLabel,{color:d.card.titleColor,fontFamily:p.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:N.chevronContainer,children:fe?jsx(Vo,{size:16,color:d.card.actionColor,strokeWidth:2}):jsx(Gt,{size:16,color:d.card.actionColor,strokeWidth:2})})]}),fe&&jsxs(View,{style:N.detailsContent,children:[jsxs(View,{style:N.detailsRow,children:[jsx(View,{style:[N.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(An,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[N.detailsLabel,{color:d.card.titleColor,fontFamily:p.regular}],children:["Price impact: ",Bt.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Ae(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(es,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:N.detailsRow,children:[jsx(View,{style:[N.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(jr,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[N.detailsLabel,{color:d.card.titleColor,fontFamily:p.regular}],children:["Slippage: Auto \u2022 ",yt.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>Ae(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(es,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:N.detailsRow,children:[jsx(View,{style:[N.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(il,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[N.detailsLabel,{color:d.card.titleColor,fontFamily:p.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(ac,{depositConfirmationMode:c,depositAddress:X,showWaitingUi:It,latestExecution:ie,onIveDeposited:me}),jsx(TouchableOpacity$1,{style:N.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[N.termsText,{color:b.primary,fontFamily:p.regular}],children:"Terms apply"})}),jsxs(bt,{visible:et,onClose:()=>Ae(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:S?.infoSheet?.borderTopLeftRadius??g,borderTopRightRadius:S?.infoSheet?.borderTopRightRadius??h,children:[jsxs(View,{style:[N.sheetHeader,{borderBottomColor:b.border}],children:[jsx(View,{style:N.sheetHeaderSpacer}),jsx(Text,{style:[N.sheetTitle,{color:d.header.titleColor,fontFamily:p.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>Ae(false),style:N.sheetCloseButton,children:jsx(st,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:N.infoSheetContent,children:[jsxs(View,{style:[N.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:N.infoCardHeader,children:[jsx(View,{style:[N.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(An,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[N.infoCardTitle,{color:d.card.titleColor,fontFamily:p.medium}],children:"Price Impact"}),jsxs(Text,{style:[N.infoCardValue,{color:d.card.titleColor,fontFamily:p.medium}],children:[Bt.toFixed(2),"%"]})]}),jsx(Text,{style:[N.infoCardDescription,{color:d.card.descriptionColor,fontFamily:p.regular}],children:"Price impact is the difference between the current market price and the price you'll receive for your swap. This occurs due to liquidity pool mechanics and trade size."})]}),jsxs(View,{style:[N.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:N.infoCardHeader,children:[jsx(View,{style:[N.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(jr,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[N.infoCardTitle,{color:d.card.titleColor,fontFamily:p.medium}],children:"Max Slippage"}),jsxs(Text,{style:[N.infoCardValue,{color:d.card.titleColor,fontFamily:p.medium}],children:[yt.toFixed(2),"%"]})]}),jsx(Text,{style:[N.infoCardDescription,{color:d.card.descriptionColor,fontFamily:p.regular}],children:"Max slippage is the maximum price difference you're willing to accept between when you submit a transaction and when it executes. Your transaction will revert if the price moves beyond this threshold."})]})]})]}),ie&&jsx(Ms,{visible:ze,status:ie.status,tokenIconUrl:ie.destination_token_metadata?.icon_urls?.find(Z=>Z.format==="png")?.url||ie.destination_token_metadata?.icon_url||Te(je,"png"),explorerUrl:ie.explorer_url,completionExplorerUrl:ie.destination_explorer_url,date:ie.created_at?new Date(ie.created_at):void 0,amountUsd:ie.source_amount_usd?parseFloat(ie.source_amount_usd):void 0,onClose:()=>it(false),borderTopLeftRadius:S?.depositStatus?.borderTopLeftRadius??g,borderTopRightRadius:S?.depositStatus?.borderTopRightRadius??h})]})}var N=StyleSheet.create({container:{flex:1,paddingHorizontal:16},loadingContainer:{padding:40,alignItems:"center",gap:12},loadingText:{fontSize:14},errorContainer:{padding:40,alignItems:"center",gap:8},errorText:{fontSize:14,textAlign:"center"},errorHint:{fontSize:12,textAlign:"center"},selectorSection:{marginBottom:12},selectorLabel:{fontSize:12,marginBottom:8},tokenSelectorButton:{flexDirection:"row",alignItems:"center",gap:12,padding:12},tokenSelectorLoading:{flexDirection:"row",alignItems:"center",gap:12,flex:1},loadingIcon:{width:40,height:40,borderRadius:20},loadingTextContainer:{flex:1},loadingLine:{height:12,borderRadius:6},tokenIconWrapper:{position:"relative"},tokenMainIcon:{width:40,height:40,borderRadius:20},tokenChainBadge:{position:"absolute",bottom:-4,right:-4,width:20,height:20,borderRadius:10,borderWidth:2},tokenSelectorInfo:{flex:1},tokenSelectorSymbol:{fontSize:14,fontWeight:"500"},tokenSelectorNetwork:{fontSize:12,marginTop:2},tokenSelectorRight:{flexDirection:"row",alignItems:"center",gap:8},minDepositText:{fontSize:12,fontWeight:"500"},qrContainer:{alignItems:"center",marginVertical:8},qrWrapper:{padding:16},qrLoading:{width:160,height:160,alignItems:"center",justifyContent:"center"},addressSection:{marginBottom:16},addressHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},addressLabel:{fontSize:12},copiedIndicator:{flexDirection:"row",alignItems:"center",gap:4},copiedText:{fontSize:12,fontWeight:"500"},addressBox:{position:"relative",paddingHorizontal:12,paddingVertical:16},addressText:{fontSize:12,fontFamily:"monospace"},addressCopyIcon:{position:"absolute",right:12,top:0,bottom:0,justifyContent:"center"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:8,paddingLeft:8,paddingRight:8},detailsContent:{paddingRight:12,paddingLeft:8,paddingBottom:12,gap:10},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,borderRadius:12,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13},chevronContainer:{},termsContainer:{alignItems:"center",paddingVertical:8},termsText:{fontSize:12,textDecorationLine:"underline"},sheetHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16},sheetHeaderSpacer:{width:28},sheetTitle:{fontSize:16,fontWeight:"500",flex:1,textAlign:"center"},sheetCloseButton:{width:28,height:28,alignItems:"center",justifyContent:"center"},infoSheetContent:{paddingHorizontal:16,paddingBottom:32,gap:16},infoCard:{borderRadius:12,padding:16,gap:12},infoCardHeader:{flexDirection:"row",alignItems:"center",gap:10},infoCardIcon:{width:32,height:32,borderRadius:16,alignItems:"center",justifyContent:"center"},infoCardTitle:{fontSize:15,fontWeight:"600",flex:1},infoCardValue:{fontSize:15,fontWeight:"600"},infoCardDescription:{fontSize:13,lineHeight:20}});var On={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},stripeLinkPay:{title:"Pay with Stripe Link",subtitle:"Apple Pay or Card"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function cC(){let{colors:e,components:t}=V(),r=useRef(new Animated.Value(.5)).current,o=t.depositMenu.card.backgroundColor,n=e.cardHover;useEffect(()=>{let s=Animated.loop(Animated.sequence([Animated.timing(r,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(r,{toValue:.5,duration:800,useNativeDriver:true})]));return s.start(),()=>s.stop()},[r]);let i=({rightIcons:s=2})=>jsxs(View,{style:[mi.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[mi.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:mi.textBlock,children:[jsx(Animated.View,{style:[mi.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[mi.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:mi.rightIcons,children:Array.from({length:s}).map((a,l)=>jsx(Animated.View,{style:[mi.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:mi.container,children:[jsx(i,{rightIcons:3}),jsx(i,{rightIcons:2}),jsx(i,{rightIcons:0})]})}var mi=StyleSheet.create({container:{paddingTop:8,paddingBottom:24,gap:8},card:{marginHorizontal:16,flexDirection:"row",alignItems:"center",paddingVertical:16,paddingHorizontal:12,gap:12},leftIcon:{width:36,height:36},textBlock:{flex:1,gap:6},titleBar:{height:12,width:"70%",borderRadius:6},subtitleBar:{height:10,width:"50%",borderRadius:5},rightIcons:{flexDirection:"row",alignItems:"center",gap:4},rightIcon:{width:20,height:20,borderRadius:10}});function dC({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:i,recipientAddress:s,destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,defaultChainType:c,defaultChainId:y,defaultTokenAddress:T,showBalance:w=false,hideDepositTracker:m=false,enableStripeLinkPay:g=false,StripeOnrampComponent:h,stripeOnrampEmail:S,stripeOnrampPhone:b,stripeMerchantIdentifier:p,stripePaymentSelectorPosition:d,stripeSkipSuccessConfirmation:C,stripeTheme:x,depositConfirmationMode:_="auto_ui",transferInputVariant:k="double_input",initialScreen:v="main",onDepositSuccess:M,onDepositError:W,sheetBorderRadius:O}){let F=O?.globalBorderTopLeftRadius,U=O?.globalBorderTopRightRadius,{colors:j,fonts:le}=V(),[Ye,_e]=useState([]),[ne,we]=useState(null),[fe,Pe]=useState("amount"),$e=v==="tracker"&&!m?"tracker":v==="transfer"?"transfer":v==="card"?"card":"main",ue=$e==="main",[J,be]=useState($e),{isAllowed:vt,isLoading:ve}=Na(o,e);useEffect(()=>{if(!e||ne)return;let he=false;return la(o).then(async X=>{if(he)return;let Ce=[];for(let pt of X?.transfer_crypto?.networks??[]){let It=pt.icon_urls.find(me=>me.format==="png")?.url||pt.icon_urls.find(me=>me.format==="svg")?.url;It&&Ce.push(oe(It));}for(let pt of X?.payment_networks?.networks??[]){let It=pt.icon_urls.find(me=>me.format==="png")?.url||pt.icon_urls.find(me=>me.format==="svg")?.url;It&&Ce.push(oe(It));}Ce.length>0&&await su(Ce),he||we(X);}).catch(console.error),()=>{he=true;}},[e,ne,o]);let qe=()=>{t();};useEffect(()=>{e&&(be($e),Pe("amount"));},[e,$e]);let Ne=useCallback(()=>{ue?(be("main"),Pe("amount")):qe();},[ue,qe]),Ve=Ye.filter(he=>he.status==="pending"||he.status==="waiting").length,it=!!(s&&a&&l&&u&&o)&&w!==false&&!!ne,ie=ve||e&&!ne,pe=vt===false,et=null;if(J==="stripe"&&h){let he=jsx(h,{publishableKey:o,email:S,phone:b,externalUserId:r,recipientAddress:s??"",destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,merchantIdentifier:p,paymentSelectorPosition:d,skipSuccessConfirmation:C,appName:ne?.project_name??"",onClose:Ne});et=x?jsx(ts,{...x,children:he}):he;}let Ae=J==="stripe"?.9:J==="transfer"||J==="card"?.94:J==="tracker"?.6:J==="main"?.5:void 0,Ke=J==="tracker"||J==="main"?.9:void 0,Ee={main:O?.main,transfer:O?.transferCrypto,card:O?.buyWithCard,stripe:O?.stripeLinkPay,tracker:O?.depositsTracker}[J],Oe=Ee?.borderTopLeftRadius??F,ar=Ee?.borderTopRightRadius??U;return jsxs(bt,{visible:e,onClose:J==="main"?qe:Ne,closeOnBackdropPress:false,enablePanDownToClose:true,showHandle:true,heightPercent:Ae,maxHeightPercent:Ke,borderTopLeftRadius:Oe,borderTopRightRadius:ar,children:[J==="main"&&jsxs(Fragment,{children:[jsx(Ur,{title:n,showBack:false,onClose:qe,showBalance:it,balanceAddress:s,balanceChainType:a,balanceChainId:l,balanceTokenAddress:u,publishableKey:o,projectName:ne?.project_name}),ie&&jsx(cC,{}),!ie&&pe&&jsxs(View,{style:Ar.centeredContainer,children:[jsx(View,{style:[Ar.iconContainer,{backgroundColor:j.cardHover}],children:jsx(ta,{size:32,color:j.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Ar.blockedTitle,{color:j.foreground,fontFamily:le.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Ar.blockedDescription,{color:j.foreground,opacity:.7,fontFamily:le.regular}],children:"There are no supported tokens available from your current location."})]}),!ie&&!pe&&jsxs(View,{style:Ar.optionsContainer,children:[jsx(Va,{onPress:()=>be("transfer"),title:On.transferCrypto.title,subtitle:On.transferCrypto.subtitle,featuredTokens:ne?.transfer_crypto?.networks}),jsx(Ba,{onPress:()=>be("card"),title:On.depositWithCard.title,subtitle:On.depositWithCard.subtitle,paymentNetworks:ne?.payment_networks?.networks}),g&&h&&jsx(Ea,{onPress:()=>be("stripe"),title:On.stripeLinkPay.title,subtitle:On.stripeLinkPay.subtitle}),!m&&jsx(Wa,{onPress:()=>be("tracker"),title:On.depositTracker.title,subtitle:On.depositTracker.subtitle,badge:Ve>0?Ve:void 0})]})]}),J==="transfer"&&jsxs(Fragment,{children:[jsx(Ur,{title:On.transferCrypto.title,showBack:false,onClose:Ne,showBalance:it,balanceAddress:s,balanceChainType:a,balanceChainId:l,balanceTokenAddress:u,publishableKey:o,projectName:ne?.project_name}),ve&&jsx(View,{style:[Ar.centeredContainer,Ar.centeredFlex],children:jsx(ActivityIndicator,{color:j.primary})}),!ve&&pe&&jsxs(View,{style:[Ar.centeredContainer,Ar.centeredFlex],children:[jsx(View,{style:[Ar.iconContainer,{backgroundColor:j.cardHover}],children:jsx(ta,{size:32,color:j.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Ar.blockedTitle,{color:j.foreground,fontFamily:le.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[Ar.blockedDescription,{color:j.foreground,opacity:.7,fontFamily:le.regular}],children:"There are no supported tokens available from your current location."})]}),!ve&&!pe&&jsx(at,{style:Ar.transferScrollContainer,contentContainerStyle:Ar.scrollContent,showsVerticalScrollIndicator:false,children:k==="single_input"?jsx(Bu,{externalUserId:r,publishableKey:o,recipientAddress:s,destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,destinationTokenSymbol:i,defaultChainType:c,defaultChainId:y,defaultTokenAddress:T,depositConfirmationMode:_,onExecutionsChange:_e,onDepositSuccess:M,onDepositError:W,borderTopLeftRadius:F,borderTopRightRadius:U,sheetBorderRadius:{tokenSelector:O?.tokenSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}}):jsx(cc,{externalUserId:r,publishableKey:o,recipientAddress:s,destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,destinationTokenSymbol:i,defaultChainType:c,defaultChainId:y,defaultTokenAddress:T,depositConfirmationMode:_,onExecutionsChange:_e,onDepositSuccess:M,onDepositError:W,borderTopLeftRadius:F,borderTopRightRadius:U,sheetBorderRadius:{tokenSelector:O?.tokenSelector,chainSelector:O?.chainSelector,infoSheet:O?.infoSheet,depositStatus:O?.depositStatus}})})]}),J==="card"&&jsxs(Fragment,{children:[jsx(Ur,{title:`Deposit ${i||"USDC"}`,showBack:fe==="onramp",onBack:()=>Pe("amount"),onClose:Ne,showBalance:it,balanceAddress:s,balanceChainType:a,balanceChainId:l,balanceTokenAddress:u,publishableKey:o,projectName:ne?.project_name}),jsx(View,{style:Ar.buyWithCardContainer,children:jsx(hc,{externalUserId:r,publishableKey:o,destinationTokenSymbol:i,recipientAddress:s,destinationChainType:a,destinationChainId:l,destinationTokenAddress:u,onDepositSuccess:M,onDepositError:W,view:fe,onViewChange:he=>Pe(he),borderTopLeftRadius:F,borderTopRightRadius:U,sheetBorderRadius:{providerModal:O?.providerModal,webView:O?.webView,currencyModal:O?.currencyModal}})})]}),J==="stripe"&&et&&jsx(View,{style:Ar.stripeLinkPayContainer,children:et}),J==="tracker"&&jsx(Ou,{active:J==="tracker",onClose:Ne,executions:Ye,externalUserId:r,publishableKey:o})]})}function Ic({theme:e="auto",...t}){return jsx(dC,{...t})}var Ar=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1},stripeLinkPayContainer:{flex:1},centeredContainer:{alignItems:"center",justifyContent:"center",paddingVertical:48,paddingHorizontal:16,minHeight:200},centeredFlex:{flex:1},iconContainer:{width:64,height:64,borderRadius:32,alignItems:"center",justifyContent:"center",marginBottom:16},blockedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},blockedDescription:{fontSize:14,textAlign:"center",maxWidth:280,lineHeight:20}});function Pc(e,t=true){return Sn({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>fl(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function Eu(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:i,enabled:s=true}=e;return Sn({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,i],queryFn:async()=>{let l=await Ci(i),u=null,c=null,y=null,T=null,w,m,g,h=l.data.some(S=>S.chains.some(b=>{let p=b.chain_type===t&&b.chain_id===r&&b.token_address.toLowerCase()===o.toLowerCase();return p&&(u=b.minimum_deposit_amount_usd,c=b.estimated_processing_time,y=b.max_slippage_percent,T=b.estimated_price_impact_percent,g=b.chain_name,m=S),p}));if(m){let S=Te(m,"png");S&&(w=oe(S));}return {isSupported:h,minimumAmountUsd:u,estimatedProcessingTime:c,maxSlippagePercent:y,priceImpactPercent:T,errorMessage:h?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:w,chainName:g}},enabled:s&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function Mu(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:i,enabled:s=true}=e;return Sn({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,i],queryFn:async()=>{let l=await hl(t,r,o,n,i);if(l.balance){let u=l.balance.token?.decimals??6,c=l.balance.token?.symbol??"",y=l.balance.amount,T=BigInt(y),w=BigInt(10**u),m=T/w,h=(T%w).toString().padStart(u,"0").replace(/0+$/,""),S=h?`${m}.${h}`:m.toString();return {balanceBaseUnit:y,balanceHuman:S,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:u,symbol:c}}return {balanceBaseUnit:"0",balanceHuman:"0",balanceUsd:"0",exchangeRate:null,decimals:6,symbol:""}},enabled:s&&(!!t&&!!r&&!!o&&!!n),staleTime:1e3*30,gcTime:1e3*60*5,refetchInterval:1e3*30,refetchOnMount:"always"})}var pC=2500,mC=3e3,fC=6e4;function zu({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:i}){let[s,a]=useState([]),[l,u]=useState(false),c=useRef(new Date),y=useRef(new Map),T=useRef(false),w=useRef(n),m=useRef(i);return useEffect(()=>{w.current=n;},[n]),useEffect(()=>{m.current=i;},[i]),useEffect(()=>{o&&!T.current&&(c.current=new Date,y.current.clear()),o||y.current.clear(),T.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let g=c.current,h=async()=>{try{let b=await pn(e,t,"withdraw"),p=new Date(g.getTime()-fC),d=[...b.data].sort((k,v)=>{let M=k.created_at?new Date(k.created_at).getTime():0;return (v.created_at?new Date(v.created_at).getTime():0)-M}),C=["pending","waiting","delayed"],x=["succeeded","failed"],_=null;for(let k of d){let v=k.created_at?new Date(k.created_at):null;if(!v||v<p)continue;let M=y.current.get(k.id);if(!M){_=k;break}if(C.includes(M)&&x.includes(k.status)){_=k;break}}if(_){let k=_,v=k.created_at?new Date(k.created_at):null;if(!v||v<c.current)return;let M=y.current.get(k.id);y.current.set(k.id,k.status),a(W=>{let O=W.findIndex(F=>F.id===k.id);if(O>=0){let F=[...W];return F[O]=k,F}return [...W,k]}),k.status==="succeeded"&&(!M||C.includes(M))?w.current?.({message:"Withdrawal completed successfully",transaction:k}):k.status==="failed"&&M!=="failed"&&m.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:k});}}catch(b){console.error("Failed to fetch withdraw executions:",b),m.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:b});}};h();let S=setInterval(h,pC);return u(true),()=>{clearInterval(S),u(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let g=async()=>{try{await ld({deposit_wallet_id:r},t);}catch{}};g();let h=setInterval(g,mC);return ()=>clearInterval(h)},[o,r,t]),{executions:s,isPolling:l}}var Uu=(e,t)=>`${t}:${e}`;function qa({tokens:e,selectedTokenSymbol:t,selectedChainKey:r,onTokenChange:o,onChainChange:n,isLoading:i=false,tokenLabel:s="Receive token",chainLabel:a="Receive chain",tokenPickerBorderTopLeftRadius:l,tokenPickerBorderTopRightRadius:u,chainPickerBorderTopLeftRadius:c,chainPickerBorderTopRightRadius:y}){let{colors:T,fonts:w,components:m}=V(),[g,h]=useState(false),[S,b]=useState(false),p=m.card,d=t?e.find(k=>k.symbol===t):void 0,C=d?.chains||[],x=r?C.find(k=>Uu(k.chain_id,k.chain_type)===r):void 0,_={backgroundColor:p.backgroundColor,borderRadius:p.borderRadius,borderWidth:p.borderWidth||1,borderColor:p.borderColor};return jsxs(View,{style:rt.row,children:[jsxs(View,{style:rt.col,children:[jsx(Text,{style:[rt.label,{color:p.labelColor,fontFamily:w.medium}],children:s}),jsxs(TouchableOpacity,{style:[rt.selectButton,_],onPress:()=>!i&&e.length>0&&h(true),activeOpacity:.7,disabled:i||e.length===0,children:[i?jsx(Text,{style:[rt.placeholder,{color:p.subtitleColor,fontFamily:w.regular}],children:"Loading..."}):d?jsxs(View,{style:rt.selectedItem,children:[jsx(Image,{source:{uri:oe(Te(d,"png"))},style:rt.icon}),jsx(Text,{style:[rt.selectedText,{color:p.titleColor,fontFamily:w.medium}],numberOfLines:1,children:d.symbol})]}):jsx(Text,{style:[rt.placeholder,{color:p.subtitleColor,fontFamily:w.regular}],children:"Select receive token"}),jsx(Gt,{size:16,color:p.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:rt.col,children:[jsx(Text,{style:[rt.label,{color:p.labelColor,fontFamily:w.medium}],children:a}),jsxs(TouchableOpacity,{style:[rt.selectButton,_,(!d||C.length===0)&&rt.disabled],onPress:()=>!i&&d&&C.length>0&&b(true),activeOpacity:.7,disabled:i||!d||C.length===0,children:[x?jsxs(View,{style:rt.selectedItem,children:[jsx(Image,{source:{uri:oe(Te(x,"png"))},style:rt.icon}),jsx(Text,{style:[rt.selectedText,{color:p.titleColor,fontFamily:w.medium}],numberOfLines:1,children:x.chain_name})]}):jsx(Text,{style:[rt.placeholder,{color:p.subtitleColor,fontFamily:w.regular}],children:"Chain"}),jsx(Gt,{size:16,color:p.actionColor,strokeWidth:2})]})]}),jsxs(bt,{visible:g,onClose:()=>h(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:l,borderTopRightRadius:u,children:[jsxs(View,{style:rt.pickerHeader,children:[jsx(View,{style:rt.pickerHeaderSpacer}),jsx(Text,{style:[rt.pickerTitle,{color:T.foreground,fontFamily:w.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:rt.pickerHeaderClose,onPress:()=>h(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(rs,{data:e,keyExtractor:k=>k.symbol,contentContainerStyle:rt.listContent,showsVerticalScrollIndicator:false,renderItem:({item:k})=>jsxs(TouchableOpacity,{style:[rt.pickerItem,{backgroundColor:k.symbol===t?T.cardHover:"transparent"}],onPress:()=>{o(k.symbol),h(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:oe(Te(k,"png"))},style:rt.pickerIcon}),jsx(Text,{style:[rt.pickerItemText,{color:T.foreground,fontFamily:w.medium}],children:k.symbol}),jsx(Text,{style:[rt.pickerItemSub,{color:T.foregroundMuted,fontFamily:w.regular}],children:k.name}),k.symbol===t&&jsx(Le,{size:18,color:T.primary,strokeWidth:2.5})]})})]}),jsxs(bt,{visible:S,onClose:()=>b(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c,borderTopRightRadius:y,children:[jsxs(View,{style:rt.pickerHeader,children:[jsx(View,{style:rt.pickerHeaderSpacer}),jsx(Text,{style:[rt.pickerTitle,{color:T.foreground,fontFamily:w.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:rt.pickerHeaderClose,onPress:()=>b(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:T.foregroundMuted,strokeWidth:2})})]}),jsx(rs,{data:C,keyExtractor:k=>Uu(k.chain_id,k.chain_type),contentContainerStyle:rt.listContent,showsVerticalScrollIndicator:false,renderItem:({item:k})=>{let v=Uu(k.chain_id,k.chain_type);return jsxs(TouchableOpacity,{style:[rt.pickerItem,{backgroundColor:v===r?T.cardHover:"transparent"}],onPress:()=>{n(v),b(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:oe(Te(k,"png"))},style:rt.pickerIcon}),jsx(Text,{style:[rt.pickerItemText,{color:T.foreground,fontFamily:w.medium}],children:k.chain_name}),v===r&&jsx(Le,{size:18,color:T.primary,strokeWidth:2.5})]})}})]})]})}var rt=StyleSheet.create({row:{flexDirection:"column",gap:10},col:{},label:{fontSize:12,marginBottom:6},selectButton:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:12,gap:6,minHeight:48},selectedItem:{flex:1,flexDirection:"row",alignItems:"center",gap:6},icon:{width:20,height:20,borderRadius:10},selectedText:{fontSize:13,flexShrink:1},placeholder:{flex:1,fontSize:13},disabled:{opacity:.4},pickerHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingTop:16,paddingBottom:12},pickerHeaderSpacer:{width:28},pickerHeaderClose:{width:28,alignItems:"flex-end"},pickerTitle:{flex:1,fontSize:16,textAlign:"center"},listContent:{paddingHorizontal:16,paddingVertical:8},pickerItem:{flexDirection:"row",alignItems:"center",paddingVertical:12,paddingHorizontal:12,borderRadius:10,gap:10},pickerIcon:{width:32,height:32,borderRadius:16},pickerItemText:{fontSize:15,flex:1},pickerItemSub:{fontSize:13}});function Hu(e){let{chainType:t,chainId:r,tokenAddress:o,recipientAddress:n,publishableKey:i,enabled:s=true}=e,a=n?.trim()||"",l=!!t&&!!r&&!!o&&a.length>0;return Sn({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,a,i],queryFn:()=>ad({chain_type:t,chain_id:r,token_address:o,recipient_address:a},i),enabled:s&&l,staleTime:1e3*60*5,gcTime:1e3*60*30,retry:1,refetchOnMount:false})}function bC(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function CC(e,t){if(e<=0)return "0";if(t===0)return BigInt(Math.round(e)).toString();let r=e.toFixed(t),[o,n=""]=r.split("."),i=n.padEnd(t,"0").slice(0,t);return (BigInt(o)*BigInt(10**t)+BigInt(i)).toString()}function wC(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function Fc({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:i,sourceTokenIconUrl:s,recipientAddressProp:a,selectedToken:l,selectedChain:u,balanceData:c,isLoadingBalance:y,minimumWithdrawAmountUsd:T,estimatedProcessingTime:w,maxSlippagePercent:m,priceImpactPercent:g,canWithdraw:h,onDepositWalletCreation:S,onWithdraw:b,onWithdrawError:p,onWithdrawSubmitted:d,onViewTracker:C}){let x="https://unifold.io/terms",_="https://unifold.io/support",{colors:k,fonts:v,components:M}=V(),[W,O]=useState(a||""),[F,U]=useState(""),[j,le]=useState(false),[Ye,_e]=useState(null),[ne,we]=useState(false),[fe,Pe]=useState(""),$e=useRef(null);useEffect(()=>{O(a||""),U(""),_e(null);},[a]);let ue=W.trim();useEffect(()=>{let me=setTimeout(()=>Pe(ue),500);return ()=>clearTimeout(me)},[ue]);let{data:J,isLoading:be,error:vt}=Hu({chainType:u?.chain_type,chainId:u?.chain_id,tokenAddress:u?.token_address,recipientAddress:fe,publishableKey:e,enabled:fe.length>5&&!!u}),ve=ue!==fe,qe=useMemo(()=>!ue||ue.length<=5||ve||be?null:vt?"Invalid address":J&&!J.valid?J.failure_code==="account_not_found"?`Account not found on ${u?.chain_name}`:J.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${l?.symbol} on ${u?.chain_name}`:"Invalid address":null,[ue,ve,be,vt,J,u,l]),Ne=!ve&&!!J?.valid&&!qe,Ve=useMemo(()=>c?.exchangeRate?parseFloat(c.exchangeRate):0,[c]),ze=useMemo(()=>c?.balanceHuman?parseFloat(c.balanceHuman):0,[c]),it=n||c?.symbol||"TOKEN",ie=c?.decimals??6,pe=useMemo(()=>{let me=parseFloat(F);return !me||me<=0?0:me},[F]),et=useMemo(()=>{let me=parseFloat(F);return !me||me<=0?0:me*Ve},[F,Ve]),Ae=useCallback(async()=>{try{let je=await hh("expo-clipboard").getStringAsync();je&&(O(je.trim()),_e(null));}catch{}},[]),Ke=useCallback(()=>{ze<=0||U(c?.balanceHuman??"0");},[ze,c]),$t=T!==null&&et>0&&et<T,Ee=pe>0&&ze>0&&pe>ze,Oe=ue.length>0&&F.trim().length>0&&pe>0&&Ne&&!$t&&!Ee&&!!c,ar=useCallback(async()=>{if(!(!l||!u||!Oe||!h)){le(true),_e(null);try{let me=await S({destinationChainType:u.chain_type,destinationChainId:u.chain_id,destinationTokenAddress:u.token_address,recipientAddress:ue}),je=CC(pe,ie),Vt=wC(pe,ie),ot={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:it,sourceTokenIconUrl:s,destinationChainType:u.chain_type,destinationChainId:u.chain_id,destinationTokenAddress:u.token_address,destinationTokenSymbol:l.symbol,destinationChainName:u.chain_name,destinationTokenIconUrl:l?oe(Te(l,"png")):void 0,amount:Vt,amountBaseUnit:je,submittedAt:new Date,withdrawIntentAddress:me.address,recipientAddress:ue};await b(ot),d(ot);}catch(me){let je=me instanceof Error?me.message:"Withdrawal failed. Please try again.",Vt=je.length>120?"Withdrawal failed. Please try again.":je;_e(Vt),p?.({message:je,error:me,code:"WITHDRAW_FAILED"});}finally{le(false);}}},[l,u,Oe,h,ue,t,r,o,it,s,F,ze,c,pe,ie,et,S,b,p,d]),he=M.input,X=M.card,Ce=M.button,pt=qe?k.error:he.borderColor,It=useMemo(()=>j?"Processing...":Ee?"Insufficient balance":$t?`Minimum $${T?.toFixed(2)}`:Ye?"Withdrawal failed \u2014 try again":"Withdraw",[j,Ee,$t,T,Ye]);return jsxs(View,{style:Xe.container,children:[jsxs(View,{children:[jsxs(View,{style:Xe.labelRow,children:[jsx(Text,{style:[Xe.label,{color:X.labelColor,fontFamily:v.medium}],children:"Recipient address"}),(ve||be)&&ue.length>5?jsx(ActivityIndicator,{size:"small",color:k.primary}):jsx(TouchableOpacity,{onPress:Ae,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(rp,{size:16,color:k.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[Xe.inputRow,{backgroundColor:he.backgroundColor,borderRadius:he.borderRadius,borderWidth:he.borderWidth,borderColor:pt}],children:jsx(TextInput,{style:[Xe.textInput,{color:he.textColor,fontFamily:v.regular}],placeholder:"Enter wallet address",placeholderTextColor:he.placeholderColor,value:W,onChangeText:me=>{O(me),_e(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>$e.current?.focus()})}),qe?jsx(Text,{style:[Xe.errorText,{color:k.error,fontFamily:v.regular}],children:qe}):null]}),jsxs(View,{children:[jsxs(Text,{style:[Xe.label,{color:X.labelColor,fontFamily:v.medium,paddingBottom:8}],children:["Amount",T!=null&&T>0&&jsx(Text,{style:{color:k.warning,fontFamily:v.regular},children:` ($${T.toFixed(2)} min)`})]}),jsxs(View,{style:[Xe.amountRow,{backgroundColor:he.backgroundColor,borderRadius:he.borderRadius,borderWidth:he.borderWidth,borderColor:he.borderColor}],children:[jsx(TextInput,{ref:$e,style:[Xe.amountInput,{color:he.textColor,fontFamily:v.regular}],placeholder:"0.00",placeholderTextColor:he.placeholderColor,value:F,onChangeText:me=>{(me===""||/^\d*\.?\d*$/.test(me))&&(U(me),_e(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(Text,{style:[Xe.unitLabel,{color:k.foregroundMuted,fontFamily:v.medium}],children:it}),jsx(TouchableOpacity,{style:[Xe.maxButton,{backgroundColor:`${k.primary}20`}],onPress:Ke,activeOpacity:.7,children:jsx(Text,{style:[Xe.maxText,{color:k.primary,fontFamily:v.medium}],children:"Max"})})]})]}),jsxs(View,{style:[Xe.detailsCard,{marginTop:24,backgroundColor:X.backgroundColor,borderRadius:X.borderRadius,borderWidth:X.borderWidth||1,borderColor:X.borderColor}],children:[jsx(TouchableOpacity,{style:Xe.detailsToggle,onPress:()=>we(!ne),activeOpacity:.7,children:jsxs(View,{style:Xe.detailsRow,children:[jsx(View,{style:[Xe.detailIcon,{backgroundColor:X.iconBackgroundColor,borderRadius:X.iconContainerBorderRadius}],children:jsx(Nr,{size:12,color:X.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Xe.detailsLabel,{color:X.titleColor,fontFamily:v.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:v.medium},children:bC(w)})]}),jsx(View,{style:{transform:[{rotate:ne?"180deg":"0deg"}]},children:jsx(Gt,{size:16,color:X.actionColor,strokeWidth:2})})]})}),ne&&jsxs(View,{style:Xe.detailsExpanded,children:[jsxs(View,{style:Xe.detailsRow,children:[jsx(View,{style:[Xe.detailIcon,{backgroundColor:X.iconBackgroundColor,borderRadius:X.iconContainerBorderRadius}],children:jsx(jr,{size:12,color:X.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Xe.detailsLabel,{color:X.titleColor,fontFamily:v.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:v.medium},children:["Auto \u2022 ",(m??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:Xe.detailsRow,children:[jsx(View,{style:[Xe.detailIcon,{backgroundColor:X.iconBackgroundColor,borderRadius:X.iconContainerBorderRadius}],children:jsx(An,{size:12,color:X.iconColor,strokeWidth:2})}),jsxs(Text,{style:[Xe.detailsLabel,{color:X.titleColor,fontFamily:v.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:v.medium},children:[(g??0).toFixed(2),"%"]})]})]})]})]}),Ye&&jsx(Text,{style:[Xe.errorText,{color:k.error,fontFamily:v.regular,textAlign:"center"}],children:Ye}),jsxs(View,{style:Xe.withdrawRow,children:[jsxs(TouchableOpacity,{style:[Xe.withdrawButton,{backgroundColor:Ce.primaryBackground,borderRadius:Ce.borderRadius,borderWidth:Ce.borderWidth,borderColor:Ce.borderColor,opacity:!Oe||!h||j?.5:1}],onPress:ar,disabled:!Oe||!h||j,activeOpacity:.8,children:[j&&jsx(ActivityIndicator,{size:"small",color:Ce.primaryText}),jsx(Text,{style:[Xe.withdrawButtonText,{color:Ce.primaryText,fontFamily:v.medium}],children:It})]}),jsxs(View,{style:Xe.footerRow,children:[jsxs(TouchableOpacity,{style:Xe.historyLink,onPress:C,activeOpacity:.7,children:[jsx(Nr,{size:14,color:k.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[Xe.historyText,{color:k.foregroundMuted,fontFamily:v.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:Xe.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(x),activeOpacity:.7,children:jsx(Text,{style:[Xe.legalText,{color:k.foregroundMuted,fontFamily:v.regular}],children:"Terms"})}),jsx(Text,{style:[Xe.legalSeparator,{color:k.foregroundMuted,fontFamily:v.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(_),activeOpacity:.7,children:jsx(Text,{style:[Xe.legalText,{color:k.foregroundMuted,fontFamily:v.regular}],children:"Help"})})]})]})]})]})}var Xe=StyleSheet.create({container:{gap:12,paddingHorizontal:16,paddingBottom:16},label:{fontSize:12},labelRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:6},inputRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,minHeight:48},textInput:{flex:1,fontSize:14,paddingVertical:8},errorText:{fontSize:12,marginTop:4},amountRow:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:6,minHeight:48,gap:8},amountInput:{flex:1,fontSize:14,paddingVertical:8},unitLabel:{fontSize:14,flexShrink:0},maxButton:{paddingHorizontal:8,paddingVertical:4,borderRadius:6},maxText:{fontSize:12,fontWeight:"600"},withdrawRow:{gap:12},footerRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},historyLink:{flexDirection:"row",alignItems:"center",gap:6},historyText:{fontSize:13},legalLinks:{flexDirection:"row",alignItems:"center",gap:6},legalText:{fontSize:13},legalSeparator:{fontSize:13},detailsCard:{paddingHorizontal:12,overflow:"hidden"},detailsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailsRow:{flexDirection:"row",alignItems:"center",gap:8},detailIcon:{width:24,height:24,alignItems:"center",justifyContent:"center"},detailsLabel:{fontSize:13,flex:1},detailsExpanded:{gap:10,paddingBottom:12},withdrawButton:{flexDirection:"row",alignItems:"center",justifyContent:"center",paddingVertical:15,gap:8},withdrawButtonText:{fontSize:16,fontWeight:"600"}});function TC(e){try{let t=new Date(e);return t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})+" at "+t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}catch{return e}}function xC(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Lc({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=V(),i=n.depositTracker.executionRow.card,s=e.status==="pending"||e.status==="waiting"||e.status==="delayed",a=e.status==="failed"||e.status==="refunded",l=a?r.error:s?r.warning:r.success,u=oe(Te(e.destination_token_metadata,"png")||cr("/icons/tokens/png/usdc.png")),c=a?"Withdrawal Failed":s?"Withdrawal Processing":"Withdrawal Completed",y=TC(e.created_at||new Date().toISOString()),T=xC(e.source_amount_usd);return jsxs(Cr,{cardTokens:i,onPress:t,contentStyle:Dn.container,children:[jsxs(View,{style:Dn.iconContainer,children:[jsx(Image,{source:{uri:u},style:Dn.tokenIcon}),jsx(View,{style:[Dn.statusBadge,{backgroundColor:l,borderColor:i.backgroundColor}],children:a?jsx(ea,{size:12,color:"#FFFFFF",strokeWidth:2.5}):s?jsx(Xi,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(Le,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Dn.textContainer,children:[jsx(Text,{style:[Dn.title,{color:i.titleColor,fontFamily:o.medium}],children:c}),jsx(Text,{style:[Dn.dateTime,{color:i.subtitleColor,fontFamily:o.regular}],children:y})]}),jsxs(View,{style:Dn.rightContainer,children:[jsx(Text,{style:[Dn.amount,{color:i.textRightColor,fontFamily:o.medium}],children:T}),jsx(_r,{size:20,color:i.actionColor,strokeWidth:2})]})]})}var Dn=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-4,right:-4,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center",borderWidth:2},textContainer:{flex:1,gap:2},title:{fontSize:16},dateTime:{fontSize:13},rightContainer:{flexDirection:"row",alignItems:"center",gap:8},amount:{fontSize:16}});function $u(e){try{let t=new Date(e),o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][t.getMonth()],n=t.getDate(),i=t.getFullYear(),s=t.getHours(),a=t.getMinutes(),l=s>=12?"PM":"AM";s=s%12||12;let u=a<10?`0${a}`:`${a}`;return `${o} ${n}, ${i} at ${s}:${u} ${l}`}catch{return e}}function Zf(e,t=6){if(!e)return "\u2014";try{let r=Number(e)/Math.pow(10,t);return r===0?"0.00":r>=1?r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function RC(e,t){if(e)try{return `$${Number(e).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}if(t)try{return `$${(Number(t)/1e6).toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`}catch{}return "$0.00"}function Xf(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function eh(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function Ka({label:e,value:t,isLast:r}){let{fonts:o,components:n}=V(),i=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:He.detailRow,children:[jsx(Text,{style:[He.detailLabel,{color:i.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[He.detailValue,{color:i.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[He.divider,{backgroundColor:i.borderColor}]})]})}function Ku({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:i}){let{colors:s,fonts:a,components:l}=V(),[u,c]=useState([]),[y,T]=useState(!!n),w=l.card,m=l.button,g=l.header,h=l.container;useEffect(()=>{sd().then(le=>c(le.data)).catch(()=>{});},[]),useEffect(()=>{T(!!n);},[e?.id]);let S=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,b=e?e.status==="failed"||e.status==="refunded":false,p=b?s.error:S?s.warning:s.success,d=b?"Failed":S?"Processing":"Completed",C=e?.destination_token_metadata?oe(Te(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?oe(t.destinationTokenIconUrl):oe(cr("/icons/tokens/png/usdc.png")),x=e?.created_at?$u(e.created_at):t.submittedAt?$u(t.submittedAt.toISOString()):$u(new Date().toISOString()),_=e?`${Zf(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${Xf(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,k=e?`${Zf(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${Xf(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,v=e?RC(e.source_amount_usd,e.source_amount_base_unit):"$0.00",M=e?ml(u,e.source_chain_type,e.source_chain_id):t.sourceChainId,W=e?ml(u,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,O=e?.transaction_hash,F=e?.explorer_url,U=e?.destination_transaction_hashes?.[0],j=e?.destination_explorer_url;return jsxs(at,{style:He.scroll,contentContainerStyle:He.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:He.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Zi,{size:22,color:g.buttonColor,strokeWidth:2})}):jsx(View,{style:He.headerSpacer}),jsx(Text,{style:[He.headerTitle,{color:g.titleColor,fontFamily:a.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:He.headerSpacer}):jsx(TouchableOpacity,{onPress:i??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(st,{size:20,color:g.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:He.iconContainer,children:[jsx(Image,{source:{uri:C},style:He.tokenIcon}),jsx(View,{style:[He.statusBadge,{backgroundColor:p}],children:b?jsx(ea,{size:10,color:"#FFFFFF",strokeWidth:3}):S?jsx(View,{style:He.spinnerDot}):jsx(Le,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:He.statusRow,children:[jsx(View,{style:[He.statusDot,{backgroundColor:p}]}),jsx(Text,{style:[He.statusText,{color:p,fontFamily:a.medium}],children:d})]}),jsx(Text,{style:[He.dateText,{color:h.subtitleColor,fontFamily:a.regular}],children:x}),jsxs(View,{style:[He.detailsCard,{backgroundColor:w.backgroundColor,borderRadius:w.borderRadius,borderWidth:w.borderWidth??1,borderColor:w.borderColor}],children:[jsx(Ka,{label:"Amount Sent",value:_}),jsx(Ka,{label:"Amount Received",value:k}),jsx(Ka,{label:"USD Value",value:v}),jsx(Ka,{label:"Source Network",value:M}),jsx(Ka,{label:"Destination Network",value:W,isLast:true})]}),jsxs(TouchableOpacity,{style:He.moreDetailsRow,onPress:()=>T(le=>!le),activeOpacity:.7,children:[jsx(Text,{style:[He.moreDetailsText,{color:h.actionTitle,fontFamily:a.regular}],children:y?"See less":n?"See more":"See more details"}),y?jsx(Vo,{size:16,color:h.actionColor,strokeWidth:2}):jsx(Gt,{size:16,color:h.actionColor,strokeWidth:2})]}),y&&jsx(View,{style:[He.detailsCard,{backgroundColor:w.backgroundColor,borderRadius:w.borderRadius,borderWidth:w.borderWidth??1,borderColor:w.borderColor}],children:O&&F?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:He.txRow,onPress:()=>Linking.openURL(F),activeOpacity:.7,children:[jsx(Text,{style:[He.txLabel,{color:w.subtitleColor,fontFamily:a.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[He.txHash,{color:w.titleColor,fontFamily:a.regular}],children:eh(O)}),jsx(Do,{size:14,color:w.actionColor,strokeWidth:2})]}),!S&&U&&j&&jsxs(Fragment,{children:[jsx(View,{style:[He.divider,{backgroundColor:w.borderColor}]}),jsxs(TouchableOpacity,{style:He.txRow,onPress:()=>Linking.openURL(j),activeOpacity:.7,children:[jsx(Text,{style:[He.txLabel,{color:w.subtitleColor,fontFamily:a.regular}],children:"Completion Tx"}),jsx(Text,{style:[He.txHash,{color:w.titleColor,fontFamily:a.regular}],children:eh(U)}),jsx(Do,{size:14,color:w.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:He.detailRow,children:jsx(Text,{style:[He.detailLabel,{color:w.subtitleColor,fontFamily:a.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:He.buttonRow,children:[jsx(TouchableOpacity,{style:[He.button,He.halfButton,{backgroundColor:m.secondaryBackground,borderRadius:m.borderRadius,borderWidth:m.borderWidth,borderColor:m.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[He.buttonText,{color:m.secondaryText,fontFamily:a.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[He.button,He.halfButton,{backgroundColor:m.primaryBackground,borderRadius:m.borderRadius,borderWidth:m.borderWidth,borderColor:m.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[He.buttonText,{color:m.primaryText,fontFamily:a.medium}],children:"Close"})})]})]})}var He=StyleSheet.create({scroll:{flex:1},container:{alignItems:"center",paddingHorizontal:20,paddingTop:8,paddingBottom:32,gap:12},headerRow:{flexDirection:"row",alignItems:"center",width:"100%",paddingTop:16,marginBottom:4},headerSpacer:{width:28},headerTitle:{flex:1,fontSize:16,textAlign:"center"},iconContainer:{position:"relative",marginTop:8},tokenIcon:{width:64,height:64,borderRadius:32},statusBadge:{position:"absolute",bottom:-2,right:-2,width:22,height:22,borderRadius:11,alignItems:"center",justifyContent:"center"},spinnerDot:{width:10,height:10,borderRadius:5,borderWidth:2,borderColor:"#FFFFFF",borderTopColor:"transparent"},statusRow:{flexDirection:"row",alignItems:"center",gap:6},statusDot:{width:8,height:8,borderRadius:4},statusText:{fontSize:15},dateText:{fontSize:13,marginTop:-4},detailsCard:{width:"100%",paddingHorizontal:16,overflow:"hidden"},detailRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:12},detailLabel:{fontSize:13,flex:1},detailValue:{fontSize:13,flexShrink:0,maxWidth:"55%",textAlign:"right"},divider:{height:StyleSheet.hairlineWidth,opacity:.5},moreDetailsRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",width:"100%",paddingHorizontal:4},moreDetailsText:{fontSize:14},txRow:{flexDirection:"row",alignItems:"center",gap:8,paddingVertical:12},txLabel:{fontSize:13},txHash:{fontSize:13,flex:1,textAlign:"right"},buttonRow:{flexDirection:"row",gap:10,width:"100%",marginTop:4},button:{paddingVertical:14,alignItems:"center",justifyContent:"center"},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:14}});function th(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Bc({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:i,components:s}=V(),a=t.length>0?t[t.length-1]:null,l=a?.status==="succeeded",u=a?.status==="failed",c={borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor};return l?jsxs(View,{style:Dt.container,children:[jsx(TouchableOpacity,{style:Dt.closeButton,onPress:r,children:jsx(st,{size:20,color:s.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Dt.iconRing,{backgroundColor:n.successBackground}],children:jsx(Le,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[Dt.title,{color:n.foreground,fontFamily:i.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[Dt.subtitle,{color:n.foregroundMuted,fontFamily:i.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",th(e.recipientAddress)]}),jsxs(View,{style:Dt.buttonRow,children:[jsx(TouchableOpacity,{style:[Dt.button,Dt.halfButton,c,{backgroundColor:s.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Dt.buttonText,{color:s.button.secondaryText,fontFamily:i.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[Dt.button,Dt.halfButton,c,{backgroundColor:s.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Dt.buttonText,{color:s.button.primaryText,fontFamily:i.medium}],children:"Close"})})]})]}):u?jsxs(View,{style:Dt.container,children:[jsx(TouchableOpacity,{style:Dt.closeButton,onPress:r,children:jsx(st,{size:20,color:s.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Dt.iconRing,{backgroundColor:n.errorBackground}],children:jsx(st,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[Dt.title,{color:n.foreground,fontFamily:i.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[Dt.subtitle,{color:n.foregroundMuted,fontFamily:i.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[Dt.button,Dt.fullButton,c,{backgroundColor:s.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Dt.buttonText,{color:s.button.primaryText,fontFamily:i.medium}],children:"Close"})})]}):jsxs(View,{style:Dt.container,children:[jsx(TouchableOpacity,{style:Dt.closeButton,onPress:r,children:jsx(st,{size:20,color:s.header.buttonColor,strokeWidth:2})}),jsx(nt,{size:80,strokeWidth:4,iconSize:68,gradientFrom:n.primary,gradientTo:n.primary,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:oe(e.sourceTokenIconUrl)},style:Dt.tokenIconFill}):jsx(View,{style:[Dt.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[Dt.title,{color:n.foreground,fontFamily:i.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[Dt.subtitle,{color:n.foregroundMuted,fontFamily:i.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",th(e.recipientAddress)]})]})}var Dt=StyleSheet.create({container:{alignItems:"center",paddingHorizontal:24,paddingTop:48,paddingBottom:24},closeButton:{position:"absolute",top:16,right:16,padding:4,zIndex:1},iconRing:{width:80,height:80,borderRadius:40,alignItems:"center",justifyContent:"center",marginBottom:20},tokenIconFill:{width:"100%",height:"100%",borderRadius:34},title:{fontSize:20,marginBottom:8,textAlign:"center"},subtitle:{fontSize:14,textAlign:"center",lineHeight:20,marginBottom:24},buttonRow:{flexDirection:"row",gap:10,width:"100%"},button:{paddingVertical:14,alignItems:"center",justifyContent:"center",borderRadius:12},halfButton:{flex:1},fullButton:{width:"100%"},buttonText:{fontSize:15}});function DC(e){let t=e.source_token_metadata?.decimals??6,r=e.source_amount_base_unit??"0",o=Number(r)/Math.pow(10,t),n=o>=1?o.toFixed(2):o.toPrecision(4).replace(/\.?0+$/,"");return {sourceChainType:e.source_chain_type,sourceChainId:e.source_chain_id,sourceTokenAddress:e.source_token_address,sourceTokenSymbol:e.source_currency?.toUpperCase()??"",sourceTokenIconUrl:oe(Te(e.source_token_metadata,"png")),destinationChainType:e.destination_chain_type,destinationChainId:e.destination_chain_id,destinationTokenAddress:e.destination_token_address,destinationTokenSymbol:e.destination_currency?.toUpperCase()??"",destinationTokenIconUrl:oe(Te(e.destination_token_metadata,"png")),amount:n,amountBaseUnit:r,submittedAt:e.created_at?new Date(e.created_at):void 0,withdrawIntentAddress:e.deposit_wallet?.address??"",recipientAddress:e.recipient_address??""}}var rh=(e,t)=>`${t}:${e}`;function VC(){let{colors:e}=V(),t=useRef(new Animated.Value(.5)).current,r=e.cardHover;return useEffect(()=>{let o=Animated.loop(Animated.sequence([Animated.timing(t,{toValue:1,duration:800,useNativeDriver:true}),Animated.timing(t,{toValue:.5,duration:800,useNativeDriver:true})]));return o.start(),()=>o.stop()},[t]),jsx(View,{style:{gap:12,paddingHorizontal:16},children:[1,2,3].map(o=>jsx(Animated.View,{style:{height:48,borderRadius:12,backgroundColor:r,opacity:t}},o))})}function Ec({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:i,defaultDestinationChainType:s,defaultDestinationChainId:a,defaultDestinationTokenAddress:l,modalTitle:u="Withdraw Crypto",onWithdraw:c,onWithdrawSuccess:y,onWithdrawError:T,heightPercent:w=.94,sheetBorderRadius:m,sourceChainType:g,sourceChainId:h,sourceTokenAddress:S,sourceTokenSymbol:b,sourceChainName:p,sourceTokenIconUrl:d}){let{colors:C,fonts:x}=V(),[_,k]=useState("form"),[v,M]=useState(g),[W,O]=useState(h),[F,U]=useState(S),[j,le]=useState(b),[Ye,_e]=useState(p),[ne,we]=useState(d),[fe,Pe]=useState(null),[$e,ue]=useState(null),[J,be]=useState(null),[vt,ve]=useState(),[qe,Ne]=useState([]),[Ve,ze]=useState(null),[it,ie]=useState("form"),pe=useRef(new Animated.Value(Dimensions.get("window").width)).current,et=useRef(null),Ae=!!v&&!!W&&!!F,{data:Ke,isLoading:$t}=Pc(r,e&&_==="form"),Ee=Ke?.data??[],{data:Oe,isLoading:ar}=Eu({sourceChainType:v,sourceChainId:W,sourceTokenAddress:F,sourceTokenSymbol:j,publishableKey:r,enabled:e&&Ae&&_==="form"}),{data:he,isLoading:X}=Mu({address:n,chainType:v,chainId:W,tokenAddress:F,publishableKey:r,enabled:e&&Ae}),{executions:Ce}=zu({userId:o,publishableKey:r,depositWalletId:vt,enabled:!!vt&&e,onWithdrawSuccess:y,onWithdrawError:T});useEffect(()=>{if(!e||_!=="tracker")return;let ce=false;return pn(o,r,"withdraw").then(xt=>{ce||Ne(xt.data);}).catch(console.error),()=>{ce=true;}},[e,_,o,r]),useEffect(()=>{e&&(et.current&&(clearTimeout(et.current),et.current=null),k("form"),M(g),O(h),U(S),le(b),_e(p),we(d),Pe(null),ue(null),be(null),ve(void 0),Ne([]),ze(null),ie("form"),pe.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{et.current&&clearTimeout(et.current);},[]),useEffect(()=>{ne||Oe?.iconUrl&&we(Oe.iconUrl);},[Oe?.iconUrl,ne]),useEffect(()=>{Ye||Oe?.chainName&&_e(Oe.chainName);},[Oe?.chainName,Ye]),useEffect(()=>{if(!Ee.length||fe)return;let ce,xt;if(s&&a)if(l)for(let Ct of Ee){let z=Ct.chains.find(Xr=>Xr.chain_type===s&&Xr.chain_id===a&&Xr.token_address.toLowerCase()===l.toLowerCase());if(z){ce=Ct,xt=z;break}}else for(let Ct of Ee){let z=Ct.chains.find(Xr=>Xr.chain_type===s&&Xr.chain_id===a);if(z){ce=Ct,xt=z;break}}ce||(ce=Ee[0]),ce&&(Pe(ce),ue(xt??ce.chains[0]??null));},[Ee,fe,s,a,l]),useEffect(()=>{_==="confirming"&&Ce.length>0&&k("details");},[_,Ce]);let pt=useCallback(()=>{t(),et.current=setTimeout(()=>{k("form"),M(g),O(h),U(S),le(b),_e(p),we(d),Pe(null),ue(null),be(null),ve(void 0),Ne([]),ze(null),ie("form"),et.current=null;},300);},[t,g,h,S,b,p,d]),It=useCallback(ce=>{let xt=Ee.find(Ct=>Ct.symbol===ce);xt&&(Pe(xt),xt.chains.length>0&&ue(xt.chains[0]));},[Ee]),me=useCallback(ce=>{if(!fe)return;let xt=fe.chains.find(Ct=>rh(Ct.chain_id,Ct.chain_type)===ce);xt&&ue(xt);},[fe]),je=useCallback(async ce=>{let xt=await dn({external_user_id:o,destination_chain_type:ce.destinationChainType,destination_chain_id:ce.destinationChainId,destination_token_address:ce.destinationTokenAddress,recipient_address:ce.recipientAddress,action_type:"withdraw"},r),Ct=un(xt.data,v??"");if(!Ct)throw new Error(`No deposit wallet found for chain type: ${v}`);return ve(Ct.id),{id:Ct.id,address:Ct.address}},[o,r,v]),Vt=useCallback(ce=>{be(ce),k("confirming");},[]),ot=useCallback(ce=>{ze(ce),pe.setValue(Dimensions.get("window").width),Animated.timing(pe,{toValue:0,duration:280,useNativeDriver:true}).start();},[pe]),Lt=useCallback(()=>{Animated.timing(pe,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>ze(null));},[pe]),Bt=$t||ar,yt=Oe?.isSupported??null,Se=_==="confirming"?"Withdrawal Status":u,Z=m?.globalBorderTopLeftRadius,Q=m?.globalBorderTopRightRadius,L=m?.main?.borderTopLeftRadius??Z,I=m?.main?.borderTopRightRadius??Q,D=m?.tokenSelector?.borderTopLeftRadius??Z,q=m?.tokenSelector?.borderTopRightRadius??Q,Fe=m?.chainSelector?.borderTopLeftRadius??Z,ke=m?.chainSelector?.borderTopRightRadius??Q,pr=(()=>{if(_!=="form"||!Ae||X||!he)return;let ce=j||he.symbol,xt=he.balanceUsd;if(xt!=null){let Xr=`$${parseFloat(xt).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return ce?`Balance: ${Xr} ${ce}`:`Balance: ${Xr}`}let Ct=he.balanceHuman;if(!(!Ct||Ct==="0"))return ce?`Balance: ${Ct} ${ce}`:`Balance: ${Ct}`})();return jsx(bt,{visible:e,onClose:pt,closeOnBackdropPress:false,enablePanDownToClose:_==="tracker"||_==="form",showHandle:_==="tracker"||_==="form",heightPercent:_==="confirming"?.3:_==="details"?.7:_==="tracker"?.6:w,maxHeightPercent:_==="tracker"?.9:void 0,borderTopLeftRadius:L,borderTopRightRadius:I,children:_==="confirming"&&J?jsx(Bc,{txInfo:J,executions:Ce,onClose:pt,onViewTracker:()=>{ie("confirming"),k("tracker");}}):_==="details"&&J?jsx(Ku,{execution:Ce.length>0?Ce[Ce.length-1]:null,txInfo:J,onClose:pt,onViewHistory:()=>{ie("details"),k("tracker");},onHeaderClose:()=>k("form")}):_==="tracker"?jsxs(View,{style:nn.trackerContainer,children:[jsx(Ur,{title:"Withdrawal History",onClose:()=>k(it)}),qe.length===0?jsx(View,{style:nn.emptyState,children:jsx(Text,{style:[nn.emptyText,{color:C.foregroundMuted,fontFamily:x.regular}],children:"No withdrawals to track yet"})}):jsx(rs,{data:qe,keyExtractor:ce=>ce.id,contentContainerStyle:nn.listContent,showsVerticalScrollIndicator:false,renderItem:({item:ce})=>jsx(Lc,{execution:ce,onPress:()=>ot(ce)})}),Ve&&jsx(Animated.View,{style:[nn.historyDetailOverlay,{backgroundColor:C.background,transform:[{translateX:pe}]}],children:jsx(Ku,{execution:Ve,txInfo:DC(Ve),onClose:pt,onBack:Lt,onViewHistory:Lt})})]}):jsxs(Fragment,{children:[jsx(Ur,{title:Se,subtitle:pr,onClose:pt}),Bt?jsx(VC,{}):yt===false?jsxs(View,{style:nn.unsupportedContainer,children:[jsx(Text,{style:[nn.unsupportedTitle,{color:C.foreground,fontFamily:x.medium}],children:"Unsupported Token"}),jsx(Text,{style:[nn.unsupportedMessage,{color:C.foregroundMuted,fontFamily:x.regular}],children:Oe?.errorMessage})]}):jsx(LC,{publishableKey:r,sourceChainType:v??"",sourceChainId:W??"",sourceTokenAddress:F??"",sourceTokenSymbol:j,sourceChainName:Ye,sourceTokenIconUrl:ne,recipientAddressProp:i,destinationTokens:Ee,selectedToken:fe,selectedChain:$e,selectedChainKey:$e?rh($e.chain_id,$e.chain_type):null,onTokenChange:It,onChainChange:me,tokensLoading:$t,balanceData:he??null,isLoadingBalance:X,sourceValidation:Oe??null,onDepositWalletCreation:je,onWithdraw:c,onWithdrawError:T,onWithdrawSubmitted:Vt,onViewTracker:()=>{ie("form"),k("tracker");},tokenSelectorLeft:D,tokenSelectorRight:q,chainSelectorLeft:Fe,chainSelectorRight:ke})]})})}function LC({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:i,sourceTokenIconUrl:s,recipientAddressProp:a,destinationTokens:l,selectedToken:u,selectedChain:c,selectedChainKey:y,onTokenChange:T,onChainChange:w,tokensLoading:m,balanceData:g,isLoadingBalance:h,sourceValidation:S,onDepositWalletCreation:b,onWithdraw:p,onWithdrawError:d,onWithdrawSubmitted:C,onViewTracker:x,tokenSelectorLeft:_,tokenSelectorRight:k,chainSelectorLeft:v,chainSelectorRight:M}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(at,{style:{flex:1,paddingTop:16},contentContainerStyle:nn.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:nn.doubleInputWrapper,children:jsx(qa,{tokens:l,selectedTokenSymbol:u?.symbol??null,selectedChainKey:y,onTokenChange:T,onChainChange:w,isLoading:m,tokenPickerBorderTopLeftRadius:_,tokenPickerBorderTopRightRadius:k,chainPickerBorderTopLeftRadius:v,chainPickerBorderTopRightRadius:M})}),jsx(Fc,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:i,sourceTokenIconUrl:s,recipientAddressProp:a,selectedToken:u,selectedChain:c,balanceData:g,isLoadingBalance:h,minimumWithdrawAmountUsd:S?.minimumAmountUsd??null,estimatedProcessingTime:S?.estimatedProcessingTime??null,maxSlippagePercent:S?.maxSlippagePercent??null,priceImpactPercent:S?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:b,onWithdraw:p,onWithdrawError:d,onWithdrawSubmitted:C,onViewTracker:x})]})})}var nn=StyleSheet.create({scrollContent:{paddingBottom:32},doubleInputWrapper:{paddingHorizontal:16,paddingBottom:12,paddingTop:4},listContent:{paddingHorizontal:16,paddingBottom:32,gap:8},trackerContainer:{flex:1,overflow:"hidden"},historyDetailOverlay:{position:"absolute",top:0,left:0,right:0,bottom:0},emptyState:{flex:1,alignItems:"center",justifyContent:"center",paddingVertical:48},emptyText:{fontSize:14},unsupportedContainer:{flex:1,alignItems:"center",justifyContent:"center",paddingHorizontal:24,paddingVertical:48},unsupportedTitle:{fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},unsupportedMessage:{fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280}});StyleSheet.create({container:{paddingHorizontal:16,paddingTop:16,paddingBottom:24,gap:16},fieldGroup:{gap:8},fieldLabel:{fontSize:12},walletCard:{paddingHorizontal:12,paddingVertical:12,minHeight:48,justifyContent:"center"},walletAddress:{fontSize:13},primaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center",marginTop:4},primaryButtonText:{fontSize:16},secondaryButton:{paddingVertical:14,alignItems:"center",justifyContent:"center"},secondaryButtonText:{fontSize:16}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var ih=createContext(null);function jC({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new Xd({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,i]=useState(false),[s,a]=useState(null),[l,u]=useState(false),[c,y]=useState(null),T=useColorScheme(),w=useRef(false);w.current||(cl({publishableKey:t}),w.current=true);let m=useMemo(()=>{let F=r?.appearance||"dark";return F==="auto"?T==="dark"?"dark":"light":F},[r?.appearance,T]);useEffect(()=>{if(!t||t.trim()===""){console.error("Unifold: publishableKey is required. Please provide a valid publishable key.");return}!t.startsWith("pk_test_")&&!t.startsWith("pk_live_")&&console.warn('Unifold: publishableKey should start with "pk_test_" or "pk_live_". Please ensure you are using a valid publishable key.'),cl({publishableKey:t});},[t]),useEffect(()=>()=>{h.current&&clearTimeout(h.current),x.current&&clearTimeout(x.current);},[]);let g=useRef(null),h=useRef(null),S=useCallback(F=>{h.current&&(clearTimeout(h.current),h.current=null),g.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),g.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),g.current=null);let U=new Promise((j,le)=>{g.current={resolve:j,reject:le};});return a(F),i(true),U},[]),b=useCallback(()=>{g.current&&(g.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),g.current=null),i(false),h.current=setTimeout(()=>{a(null),h.current=null;},200);},[]),p=useCallback(F=>{s?.onSuccess&&s.onSuccess(F),g.current&&(g.current.resolve(F),g.current=null);},[s]),d=useCallback(F=>{console.error("[UnifoldProvider] Deposit error:",F),s?.onError&&s.onError(F),g.current&&(g.current.reject(F),g.current=null);},[s]),C=useRef(null),x=useRef(null),_=useRef(void 0),k=useCallback(F=>{x.current&&(clearTimeout(x.current),x.current=null),C.current&&(console.warn("[UnifoldProvider] A withdrawal is already in progress. Cancelling previous withdrawal."),C.current.reject({message:"Withdrawal cancelled - new withdrawal started",code:"WITHDRAW_SUPERSEDED"}),C.current=null);let U=new Promise((j,le)=>{C.current={resolve:j,reject:le};});return _.current=F.onClose,y(F),u(true),U},[]),v=useCallback(()=>{C.current&&(C.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),C.current=null),_.current?.(),_.current=void 0,u(false),x.current=setTimeout(()=>{y(null),x.current=null;},200);},[]),M=useCallback(F=>{c?.onSuccess&&c.onSuccess(F),C.current&&(C.current.resolve(F),C.current=null);},[c]),W=useCallback(F=>{console.error("[UnifoldProvider] Withdraw error:",F),c?.onError&&c.onError(F),C.current&&(C.current.reject(F),C.current=null);},[c]),O=useMemo(()=>({publishableKey:t,beginDeposit:S,closeDeposit:b,beginWithdraw:k,closeWithdraw:v}),[t,S,b,k,v]);return jsx(ru,{client:o,children:jsx(ih.Provider,{value:O,children:jsxs(ts,{mode:m,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,s&&jsx(Ic,{visible:n,onClose:b,publishableKey:t,modalTitle:r?.modalTitle,externalUserId:s.externalUserId,destinationChainType:s.destinationChainType,destinationChainId:s.destinationChainId,destinationTokenSymbol:s.destinationTokenSymbol,recipientAddress:s.recipientAddress,destinationTokenAddress:s.destinationTokenAddress,defaultChainType:s.defaultChainType,defaultChainId:s.defaultChainId,defaultTokenAddress:s.defaultTokenAddress,showBalance:s.showBalance,stripeOnrampEmail:s.stripeOnrampEmail,stripeOnrampPhone:s.stripeOnrampPhone,stripeTheme:{mode:m,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components},depositConfirmationMode:s.depositConfirmationMode??"auto_ui",initialScreen:s.initialScreen,hideDepositTracker:r?.hideDepositTracker,transferInputVariant:r?.transferInputVariant,enableStripeLinkPay:r?.enableStripeLinkPay,stripeMerchantIdentifier:r?.stripeMerchantIdentifier,stripePaymentSelectorPosition:r?.stripePaymentSelectorPosition,stripeSkipSuccessConfirmation:r?.stripeSkipSuccessConfirmation,StripeOnrampComponent:r?.enableStripeLinkPay?hm():void 0,onDepositSuccess:p,onDepositError:d,theme:m,sheetBorderRadius:r?.sheetBorderRadius}),c&&jsx(Ec,{visible:l,onClose:v,publishableKey:t,externalUserId:c.externalUserId,senderAddress:c.senderAddress,recipientAddress:c.recipientAddress,sourceChainType:c.sourceChainType,sourceChainId:c.sourceChainId,sourceTokenAddress:c.sourceTokenAddress,sourceTokenSymbol:c.sourceTokenSymbol,defaultDestinationChainType:c.defaultDestinationChainType,defaultDestinationChainId:c.defaultDestinationChainId,defaultDestinationTokenAddress:c.defaultDestinationTokenAddress,onWithdraw:c.withdraw,onWithdrawSuccess:M,onWithdrawError:W,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function $C(){let e=useContext(ih);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
+ export{Pl as AmountScreen,bt as BottomSheet,Ol as KYCWizardScreen,Ul as OnrampScreen,Hl as StripeOnramp,mm as StripeOnrampPreconfigure,jC as UnifoldProvider,Te as getPreferredIcon,xl as getStripePublishableKey,fl as getSupportedDestinationTokens,oe as normalizeIconUrl,Nl as registerStripeOnramp,cp as setDevApiUrl,Tl as setStripeOnrampApiUrl,kl as setStripeOnrampPublishableKey,Na as useAllowedCountry,Fl as useStripeOnramp,V as useTheme,$C as useUnifold};