@unifold/connect-react-native 0.1.35-beta-003 → 0.1.35-beta-005

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 Dn from'react';import {createContext,useContext,useRef,useState,useMemo,useEffect,useCallback,useId,Fragment as Fragment$1}from'react';import {StyleSheet,Platform,Modal,StatusBar,View,TouchableOpacity,Text,ActivityIndicator,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Animated,Easing,Dimensions,Image,Linking,Clipboard,ScrollView}from'react-native';import Bt,{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 sf,{BottomSheetBackdrop,BottomSheetView,BottomSheetScrollView,BottomSheetFlatList}from'@gorhom/bottom-sheet';import {GestureHandlerRootView,TouchableOpacity as TouchableOpacity$1}from'react-native-gesture-handler';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import kc from'@react-native-async-storage/async-storage';import wh from'expo-constants';import tg from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var zd=e=>{throw TypeError(e)};var Em=(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 Ul=(e,t,r)=>t.has(e)||zd("Cannot "+r);var p=(e,t,r)=>(Ul(e,t,"read from private field"),r?r.call(e):t.get(e)),J=(e,t,r)=>t.has(e)?zd("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),L=(e,t,r,o)=>(Ul(e,t,"write to private field"),t.set(e,r),r),Le=(e,t,r)=>(Ul(e,t,"access private method"),r);var bs=(e,t,r,o)=>({set _(n){L(e,t,n);},get _(){return p(e,t,o)}});var Hl={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)"}},Nl=Hl;function pa(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function Cs(e,t,r){let o=r?t?.[r]:void 0,n=(d,g,k)=>{let h=o?.[d]?.[g];if(h!==void 0)return h;let b=t?.[d]?.[g];return b!==void 0?b:k},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:pa(a,i)},transferCrypto:{depositAddress:{card:pa(a,s)}},depositCard:{quoteProvider:{card:pa(a,l)}},depositTracker:{executionRow:{card:pa(a,m)}}}}function jl(e,t,r){let n={...Hl[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var $l=createContext(null);function V(){let e=useContext($l);if(!e){let t=Nl.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:Cs(t,void 0,"dark"),isDark:true}}return e}function ht({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:a,gradientTo:i}){let{colors:s}=V(),l=a??s.warning,m=i??"#FBBF24",d=useRef(new Animated.Value(0)).current,g=useId(),k=useMemo(()=>`circularProgressGrad_${g.replace(/[^a-zA-Z0-9_-]/g,"")}`,[g]),h=(e-t)/2,b=2*Math.PI*h,w=e/2,c=o??Math.max(0,Math.round(e-t*2-8)),S=(e-c)/2;useEffect(()=>{let u=Animated.loop(Animated.timing(d,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return u.start(),()=>u.stop()},[d]);let y=d.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:y}]},children:jsxs(Bt,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:k,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:l}),jsx(Stop,{offset:"100%",stopColor:m})]})}),jsx(Circle,{cx:w,cy:w,r:h,stroke:`url(#${k})`,strokeWidth:t,fill:"none",strokeDasharray:`${b*.75} ${b*.25}`,strokeLinecap:"round",rotation:-90,origin:`${w}, ${w}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:S+1.5,left:S,width:c,height:c},children:r}):null]})}function Kl({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 _i({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 bo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 ws({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 tt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 Vr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 Ri({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 Pt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 Hn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 qe({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 Ss({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 Gl({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 Co({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 mn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 fa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 wo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 ha({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 Ii({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 fn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 ga({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 ks({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 jd({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 vi({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 h=o?.[l];return jl(l,h,r)},[l,o,r]),d=useMemo(()=>Cs(m,i,l),[m,i,l]),g=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]),k=useMemo(()=>({mode:l,colors:m,fonts:g,components:d,isDark:l==="dark"}),[l,m,g,d]);return jsx($l.Provider,{value:k,children:e})}function ct({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:d=24,borderTopRightRadius:g=24}){let{colors:k,components:h}=V(),b=useRef(null),w=i!=null&&i>=1,[c,S]=useState(false),y=useRef(false),u=useMemo(()=>{if(i!=null){let R=[`${Math.round(i*100)}%`];return s!=null&&s>i&&R.push(`${Math.round(s*100)}%`),R}},[i,s]),f=u?u.join("-"):"dynamic",x=l&&u&&u.length>1?u.length-1:0;useEffect(()=>{e?(y.current=false,S(true)):c&&(y.current=true,b.current?b.current.close():S(false));},[e,c]);let _=useCallback(R=>{R===-1&&(S(false),y.current||t(),y.current=false);},[t]),T=useCallback(R=>jsx(BottomSheetBackdrop,{...R,disappearsOnIndex:-1,appearsOnIndex:0,opacity:.5,pressBehavior:o?"close":"none"}),[o]);if(!c)return null;let C=w||m?0:Platform.OS==="ios"?34:24;return jsx(Modal,{visible:true,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:()=>{b.current?b.current.close():t();},children:jsx(GestureHandlerRootView,{style:[xs.container,Platform.OS==="android"&&{paddingTop:StatusBar.currentHeight}],children:jsx(sf,{ref:b,index:x,snapPoints:u,enableDynamicSizing:u==null,enablePanDownToClose:n,onChange:_,backdropComponent:T,handleIndicatorStyle:a?[xs.handleIndicator,{backgroundColor:k.border}]:xs.hiddenHandle,handleStyle:a?xs.handleArea:xs.hiddenHandleArea,backgroundStyle:[{backgroundColor:k.background,borderTopLeftRadius:w?0:d,borderTopRightRadius:w?0:g},h.sheet.shadowColor?{shadowColor:h.sheet.shadowColor,shadowOffset:h.sheet.shadowOffset,shadowOpacity:h.sheet.shadowOpacity,shadowRadius:h.sheet.shadowRadius,elevation:h.sheet.elevation}:void 0],children:u?jsx(View,{style:{flex:1,paddingBottom:C},children:r}):jsx(BottomSheetView,{style:{paddingBottom:C},children:r})},f)})})}var xs=StyleSheet.create({container:{flex:1},handleArea:{paddingTop:12,paddingBottom:4},handleIndicator:{width:36,height:4,borderRadius:2},hiddenHandle:{height:0,opacity:0},hiddenHandleArea:{padding:0,height:0}});var df="https://api.unifold.io",Yl="__UnifoldDevApiBaseUrl__",Cr="pk_test_123",ya={};function uf(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[Yl];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function qt(){return uf()??df}function ba(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.'),Cr=e.publishableKey;}e.defaultConfig&&(ya=e.defaultConfig);}function Kd(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[Yl]=t:delete globalThis[Yl];}function _s(){return qt()}function Ca(){return Cr}function Lr(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 Ht(e){let t=e.startsWith("/")?e:`/${e}`;return `${qt()}/api/public${t}`}function Z(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,qt()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${qt()}${e}`:`${qt()}/api/public${e}`:""}async function Uo(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||ya.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||ya.destinationChainId||"8453",destination_token_address:e?.destination_token_address||ya.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||Cr;Lr(n);let a=await fetch(`${qt()}/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 Ho(e,t){return e.find(r=>r.chain_type===t)}async function No(e,t,r){let o=t||Cr;Lr(o);let n=await fetch(`${qt()}/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 wa(e,t){let r=t||Cr;Lr(r);let o=await fetch(`${qt()}/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 ge(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 Nn(e,t){let r=e||Cr;Lr(r);let o=`${qt()}/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 Jl(e,t){let r=t||Cr;Lr(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${qt()}/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 Sa(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function Zl(e,t){let r=t||Cr;Lr(r);let o=await fetch(`${qt()}/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 Xl(e,t){let r=t||Cr;Lr(r);let o=await fetch(`${qt()}/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 ec(e,t){let r=t||Cr;Lr(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(`${qt()}/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 tc(e){let t=e||Cr;Lr(t);let r=await fetch(`${qt()}/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 Di(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 Rs(e){let t=e||Cr;Lr(t);let r=await fetch(`${qt()}/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 rc(){let e=await fetch(`${qt()}/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 ka(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 Is(){let e=await fetch(`${qt()}/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 Ta(e){let t=e||Cr;Lr(t);let r=await fetch(`${qt()}/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 oc(e,t){let r=t||Cr;Lr(r);let o=await fetch(`${qt()}/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 nc(e,t){return wa(e.deposit_wallet_id,t)}async function xa(e,t,r,o,n){let a=n||Cr;Lr(a);let i=await fetch(`${qt()}/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 Yd({size:e=28}){return jsx(Bt,{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 Zd({size:e=28}){return jsxs(Bt,{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 tu({size:e=28}){return jsxs(Bt,{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 ru({size:e=28}){return jsxs(Bt,{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 ou({size:e=28}){return jsx(Bt,{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 _a=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:Yd},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:Zd},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:tu},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:ru},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:ou}];function nu(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function Ra(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 Ia(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=_a.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=_a.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function Jt({onPress:e,title:t,variant:r="close"}){let{components:o,fonts:n}=V(),a=r==="back",i=a?jsx(Ri,{size:22,color:o.header.buttonColor,strokeWidth:2.5}):jsx(tt,{size:20,color:o.header.buttonColor,strokeWidth:2}),s=jsx(TouchableOpacity,{style:hn.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:a?"Back":"Close",children:i});return t?jsxs(View,{style:hn.headerWithTitle,children:[a?s:jsx(View,{style:hn.headerSide}),jsx(Text,{style:[hn.headerTitleText,{color:o.header.titleColor},...n.bold?[{fontFamily:n.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),a?jsx(View,{style:hn.headerSide}):s]}):jsxs(View,{style:a?hn.headerWithTitle:hn.header,children:[a?s:jsx(View,{style:hn.headerSpacer}),!a&&s]})}var va={paddingTop:60,paddingBottom:16},hn=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...va},headerWithTitle:{flexDirection:"row",alignItems:"center",...va},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 wr({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=V();return e?jsx(Text,{style:[iu.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[iu.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var iu=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function co({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 dc({quote:e,label:t,address:r,last:o,hideDivider:n}){let[a,i]=useState(false),{colors:s,components:l}=V(),m=()=>{Clipboard.setString(r),i(true),setTimeout(()=>i(false),2e3);},d=nu(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:d}),jsx(TouchableOpacity,{onPress:m,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:a?jsx(qe,{size:14,color:s.success,strokeWidth:2.5}):jsx(Hn,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var Pa={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function lu({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=V(),a=e.toLowerCase(),i=Pa[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 Oa({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:a}){let{colors:i,components:s,fonts:l}=V(),m=Ht(`/icons/currencies/png/${e.toLowerCase()}.png`),d=Ia(r);return jsxs(View,{style:[Gr.diagram,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor},a],children:[jsxs(View,{style:Gr.step,children:[jsx(Image,{source:{uri:m},style:Gr.iconImage}),jsx(Text,{style:[Gr.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You bought"}),jsx(Text,{style:[Gr.value,{color:s.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(Vr,{size:16,color:i.foregroundMuted,strokeWidth:2}),jsxs(View,{style:Gr.step,children:[jsxs(View,{style:Gr.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:Gr.tokenIcon}):jsx(View,{style:[Gr.tokenIcon,{backgroundColor:Pa[t.toLowerCase()]??i.primary}]}),n?jsx(Image,{source:{uri:n},style:[Gr.networkBadge,{borderColor:i.background}]}):null]}),jsx(Text,{style:[Gr.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[Gr.value,{color:s.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",d]})]})]})}var Gr=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 Li(){let{colors:e,fonts:t,components:r}=V(),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:48},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"}},d={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:24},numpadRow:{flexDirection:"row",justifyContent:"space-between"},numpadKey:{flex:1,height:68,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:20,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}:{}}},g={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}:{}}},k=Math.max(16,Math.min(l,22)),h={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,paddingHorizontal:16,paddingVertical:16},swapCardTop:{borderTopLeftRadius:k,borderTopRightRadius:k,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:k,borderBottomRightRadius:k,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"}},w={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:g,pm:h,wallet:b,flow:w,amount:d}},[e,t,o,n,a,i,s])}function Ef({size:e=24}){let t=e,r=e*(471/750);return jsxs(Bt,{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 Mf({size:e=24}){return jsx(Bt,{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 zf({size:e=24}){return jsx(Bt,{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 pc({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(_i,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(Ef,{size:t}):o.includes("mastercard")?jsx(Mf,{size:t}):o.includes("amex")||o.includes("american express")?jsx(zf,{size:t}):jsx(_i,{size:t*.75,color:r,strokeWidth:1.75})}var Uf=[50,100,500],Hf=[["1","2","3"],["4","5","6"],["7","8","9"],["\u232B","0","."]];function mu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Nf(e){return e.card?`${mu(e.card.brand)} ${mu(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Da({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:d=[],onAddPaymentMethod:g,onConfirm:k,onCancel:h,sheetBorderTopLeftRadius:b,sheetBorderTopRightRadius:w}){let c=Li(),{colors:S,components:y}=V(),u=b??y.card.borderRadius,f=w??y.card.borderRadius,[x,_]=useState(e),[T,C]=useState(r?"apple_pay":d.length>0?d[0].id:null),R=useRef(false),B=M=>{R.current=true,C(M);};useEffect(()=>{R.current||r||d.length>0&&C(d[0].id);},[d,r]);let[E,D]=useState(false),[P,q]=useState("select"),[j,fe]=useState(null),Ke=useRef(false);useEffect(()=>{s&&l&&/saving/i.test(l)&&q("card");},[s,l]);let De=T==="apple_pay",G=1e3,Se=De?G:n,he=Se!=null&&Se>0,Ie=useMemo(()=>{if(o)return [];let M=Uf.map(W=>({label:`$${W}`,amount:String(W),disabled:false}));return De?M.push({label:`$${G}`,amount:String(G),disabled:false}):M.push({label:"MAX",amount:he?String(Se):"0",disabled:!he}),M},[o,he,Se,De]),Ge=M=>{if(M==="\u232B"){_(W=>W.slice(0,-1));return}if(M==="."){if(x.includes("."))return;_(W=>W===""?"0.":W+".");return}_(W=>{let se=W.indexOf(".");return se!==-1&&W.length-se>2?W:W==="0"&&M!=="."?M:W+M});},ke=x===""?"0":x,Y=parseFloat(x),Te=x!==""&&!isNaN(Y)&&Y>0,st=r||d.length>0,We=a==="header",Ye=useMemo(()=>{let M=[];r&&M.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let W of d)M.push({id:W.id,label:Nf(W),hint:W.card?`Expires ${W.card.exp_month}/${W.card.exp_year}`:W.type,brand:W.card?.brand,isApplePay:false});return M},[r,d]),Ae=Ye.find(M=>M.id===T),Me=T!=null&&T!=="apple_pay",pe=Ae?Ae.label:Me&&j?j:Me?"Card":"Pay With",ee=Ae?!Ae.isApplePay:Me,be=Ae?.brand??j??void 0,pt=st?jsx(TouchableOpacity,{style:[We?c.amount.paymentRowHeader:c.amount.paymentRow,s&&{opacity:.5}],onPress:()=>{s||(q("select"),D(true));},activeOpacity:.7,disabled:s,children:jsxs(View,{style:c.amount.paymentLeft,children:[Ae?.isApplePay?jsx(Text,{style:c.amount.applePayIcon,children:"\uF8FF"}):ee?jsx(pc,{sublabel:be,size:20}):null,jsx(Text,{style:c.amount.paymentLabel,children:pe}),jsx(Pt,{size:12,color:c.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:c.form.screen,children:[jsx(Jt,{onPress:h,title:"Enter amount"}),We&&pt,jsxs(View,{style:c.form.content,children:[jsxs(View,{style:c.amount.amountContainer,children:[jsxs(Text,{style:[c.amount.amountText,ke==="0"&&c.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",ke]}),jsx(Text,{style:c.amount.currencyLabel,children:t.toUpperCase()})]}),!We&&pt,Ie.length>0&&jsx(View,{style:c.amount.quickRow,children:Ie.map(M=>{let W=!M.disabled&&x===M.amount&&x!=="";return jsx(TouchableOpacity,{style:[c.amount.quickPill,W&&{backgroundColor:S.primary},M.disabled&&{opacity:.4}],activeOpacity:.7,disabled:M.disabled||s,onPress:()=>_(M.amount),children:jsx(Text,{style:[c.amount.quickPillText,W&&{color:S.primaryForeground}],children:M.label})},M.label)})}),jsx(View,{style:c.amount.numpad,children:Hf.map((M,W)=>jsx(View,{style:c.amount.numpadRow,children:M.map(se=>jsx(TouchableOpacity,{style:[c.amount.numpadKey,s&&{opacity:.3}],onPress:()=>Ge(se),activeOpacity:.6,disabled:s,children:jsx(Text,{style:se==="\u232B"?c.amount.backspaceText:c.amount.numpadKeyText,children:se})},se))},W))}),jsx(TouchableOpacity,{style:[c.form.continueBtn,(!Te||s)&&c.form.continueBtnDisabled],onPress:()=>Te&&!s&&k(x,T),disabled:!Te||s,children:s?jsx(ActivityIndicator,{size:"small",color:S.primaryForeground}):jsx(Text,{style:[c.form.continueBtnText,!Te&&c.form.continueBtnTextDisabled],children:"Continue"})}),!E&&m?jsx(Text,{style:c.amount.inlineError,children:m}):!E&&s&&l&&__DEV__?jsx(Text,{style:c.amount.inlineStatus,children:l}):null]}),jsx(ct,{visible:E,onClose:()=>{s||(D(false),q("select"));},closeOnBackdropPress:!s,enablePanDownToClose:!s,showHandle:false,heightPercent:.5,borderTopLeftRadius:u,borderTopRightRadius:f,children:jsx(View,{style:c.amount.sheetContent,children:P==="select"?jsxs(Fragment,{children:[jsxs(View,{style:c.amount.sheetTitleRow,children:[jsx(Text,{style:c.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity,{onPress:()=>D(false),activeOpacity:.7,style:c.amount.sheetCloseBtn,children:jsx(tt,{size:16,color:S.foregroundMuted,strokeWidth:2.5})})]}),jsxs(BottomSheetScrollView,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[Ye.map(M=>{let W=T===M.id;return jsxs(TouchableOpacity,{style:[c.amount.sheetOption,W&&{borderColor:S.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{B(M.id),fe(M.isApplePay?null:M.label),D(false);},children:[jsxs(View,{style:c.amount.sheetOptionLeft,children:[jsx(View,{style:c.amount.sheetOptionIcon,children:M.isApplePay?jsx(Text,{style:c.amount.applePayIcon,children:"\uF8FF"}):jsx(pc,{sublabel:M.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:c.amount.sheetOptionLabel,children:M.label}),jsx(Text,{style:c.amount.sheetOptionHint,children:M.hint})]})]}),W&&jsx(qe,{size:18,color:S.primary,strokeWidth:2.5})]},M.id)}),jsx(TouchableOpacity,{style:c.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!Ke.current){Ke.current=true;try{let M=await g?.();M&&(B(M.token),fe(M.sublabel),D(!1));}finally{Ke.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,{onPress:()=>{s||q("select");},activeOpacity:.7,style:c.amount.sheetBackBtn,children:jsx(Ri,{size:20,color:S.foreground,strokeWidth:2})}),jsx(Text,{style:c.amount.sheetTitle,children:"Pay With"})]}),s?jsxs(View,{style:c.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:S.primary}),__DEV__?jsx(Text,{style:c.amount.sheetStatusText,children:l||"Loading Stripe Link..."}):null]}):m?jsxs(Fragment,{children:[jsx(View,{style:c.amount.sheetError,children:jsx(Text,{style:c.amount.sheetErrorText,children:m})}),jsx(TouchableOpacity,{style:c.form.continueBtn,onPress:()=>{i&&Te&&i(false,x);},children:jsx(Text,{style:c.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:c.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:S.primary}),__DEV__?jsx(Text,{style:c.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})})]})}var Fs=4;function Fa({initialData:e={},loading:t=false,onComplete:r,onCancel:o}){let n=Li(),{colors:a,fonts:i,components:s}=V(),l=s.input.placeholderColor,[m,d]=useState(1),[g,k]=useState(e.firstName??""),[h,b]=useState(e.lastName??""),[w,c]=useState(e.dobMonth??""),[S,y]=useState(e.dobDay??""),[u,f]=useState(e.dobYear??""),[x,_]=useState(e.addressLine1??""),[T,C]=useState(e.addressLine2??""),[R,B]=useState(e.city??""),[E,D]=useState(e.state??""),[P,q]=useState(e.postalCode??""),[j,fe]=useState(e.country??"US"),[Ke,De]=useState(e.idNumber??""),G=useRef(null),Se=useRef(null),he=useRef(null),Ie=useRef(null),Ge=useRef(null),ke=useRef(null),Y=useRef(null),Te=useRef(null),st=()=>{switch(m){case 1:return g.trim().length>0&&h.trim().length>0;case 2:return w.length===2&&S.length===2&&u.length===4;case 3:return x.trim().length>0&&R.trim().length>0&&E.trim().length>0&&P.trim().length>0;case 4:return Ke.trim().length>0;default:return false}},We=()=>{st()&&(m<Fs?d(pe=>pe+1):r({firstName:g,lastName:h,idNumber:Ke,dobMonth:w,dobDay:S,dobYear:u,addressLine1:x,addressLine2:T,city:R,state:E,postalCode:P,country:j}));},Ye=()=>{m>1?d(pe=>pe-1):o();},Ae=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],Ee=["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."],Me=[Wt.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:Wt.header,children:[jsx(View,{style:Wt.headerSide,children:jsx(TouchableOpacity,{style:Wt.iconButton,onPress:Ye,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:m>1?"Back":"Cancel",children:jsx(ws,{size:20,color:s.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:Wt.headerCenter,children:jsxs(Text,{style:Me,children:[m," of ",Fs]})}),jsx(View,{style:Wt.headerSide,children:jsx(TouchableOpacity,{style:Wt.iconButton,onPress:o,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(tt,{size:20,color:s.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:Wt.progressTrack,children:Array.from({length:Fs}).map((pe,ee)=>jsx(View,{style:[Wt.progressSegment,{backgroundColor:ee<m||ee+1===m?a.primary:a.border}]},ee))}),jsxs(BottomSheetScrollView,{style:n.form.flex,contentContainerStyle:Wt.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:n.form.title,children:Ae[m-1]}),jsx(Text,{style:n.form.subtitle,children:Ee[m-1]}),m===1&&jsxs(Fragment,{children:[jsx($o,{form:n.form,label:"First name",children:jsx(TextInput,{style:n.form.input,placeholder:"Jane",placeholderTextColor:l,value:g,onChangeText:k,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>G.current?.focus()})}),jsx($o,{form:n.form,label:"Last name",children:jsx(TextInput,{ref:G,style:n.form.input,placeholder:"Doe",placeholderTextColor:l,value:h,onChangeText:b,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:We})})]}),m===2&&jsxs(View,{style:Wt.dobRow,children:[jsxs(View,{style:Wt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Wt.dobLabel],children:"Month"}),jsx(TextInput,{style:[n.form.input,Wt.dobInput],placeholder:"MM",placeholderTextColor:l,value:w,onChangeText:pe=>{let ee=pe.replace(/\D/g,"").slice(0,2);c(ee),ee.length===2&&Se.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Wt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Wt.dobLabel],children:"Day"}),jsx(TextInput,{ref:Se,style:[n.form.input,Wt.dobInput],placeholder:"DD",placeholderTextColor:l,value:S,onChangeText:pe=>{let ee=pe.replace(/\D/g,"").slice(0,2);y(ee),ee.length===2&&he.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Wt.dobColWide,children:[jsx(Text,{style:[n.form.fieldLabel,Wt.dobLabel],children:"Year"}),jsx(TextInput,{ref:he,style:[n.form.input,Wt.dobInput],placeholder:"YYYY",placeholderTextColor:l,value:u,onChangeText:pe=>{let ee=pe.replace(/\D/g,"").slice(0,4);f(ee);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:We})]})]}),m===3&&jsxs(Fragment,{children:[jsx($o,{form:n.form,label:"Street address",children:jsx(TextInput,{style:n.form.input,placeholder:"123 Main St",placeholderTextColor:l,value:x,onChangeText:_,returnKeyType:"next",onSubmitEditing:()=>Ie.current?.focus()})}),jsx($o,{form:n.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:Ie,style:n.form.input,placeholder:"Apt 2",placeholderTextColor:l,value:T,onChangeText:C,returnKeyType:"next",onSubmitEditing:()=>Ge.current?.focus()})}),jsx($o,{form:n.form,label:"City",children:jsx(TextInput,{ref:Ge,style:n.form.input,placeholder:"San Francisco",placeholderTextColor:l,value:R,onChangeText:B,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>ke.current?.focus()})}),jsxs(View,{style:Wt.row,children:[jsx(View,{style:[n.form.flex,{marginRight:8}],children:jsx($o,{form:n.form,label:"State",children:jsx(TextInput,{ref:ke,style:n.form.input,placeholder:"NY",placeholderTextColor:l,value:E,onChangeText:pe=>D(pe.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>Y.current?.focus()})})}),jsx(View,{style:n.form.flex,children:jsx($o,{form:n.form,label:"ZIP code",children:jsx(TextInput,{ref:Y,style:n.form.input,placeholder:"11201",placeholderTextColor:l,value:P,onChangeText:q,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>Te.current?.focus()})})})]}),jsx($o,{form:n.form,label:"Country",children:jsx(TextInput,{ref:Te,style:n.form.input,placeholder:"US",placeholderTextColor:l,value:j,onChangeText:pe=>fe(pe.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:We})})]}),m===4&&jsxs($o,{form:n.form,label:"Social Security Number",children:[jsx(TextInput,{style:n.form.input,placeholder:"123-45-6789",placeholderTextColor:l,value:Ke,onChangeText:De,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:We}),jsx(Text,{style:[n.form.hint,Wt.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:n.form.footer,children:t&&m===Fs?jsx(View,{style:[n.form.continueBtn,n.form.loaderInButton],children:jsx(ht,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[n.form.continueBtn,!st()&&n.form.continueBtnDisabled],onPress:We,disabled:!st(),children:jsx(Text,{style:[n.form.continueBtnText,!st()&&n.form.continueBtnTextDisabled],children:m===Fs?"Submit":"Continue"})})})]})})}function $o({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var Wt=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 hu="",gu;function Va(e){hu=e;}function La(e){gu=e;}function Er(){let e=hu||Ca();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function Mr(){return gu??_s()}async function Ba(){let e=`${Mr()}/v1/public/onramps/headless/stripe/config`,t=Er(),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 yc(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":Er(),"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 yu(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e})});if(!t.ok)throw new Error(`Failed to exchange auth intent for tokens: ${t.status}`);return t.json()}async function bc(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})}),r=await t.json().catch(()=>({}));if(!t.ok)throw new Error(r?.message??`Failed to refresh OAuth token: ${t.status}`);return r}async function bu(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(`${Mr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":Er(),"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 Cu(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":Er(),"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 Wa(e,t){let r=`${Mr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Er(),"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 wu(e,t){let r=`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Er(),"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 Cc(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":Er(),"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 Su(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(`${Mr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":Er(),"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 wc(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":Er(),"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 ku(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(`${Mr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":Er(),"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 Sc(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 Tu(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":Er()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}var Tc="@unifold/stripe_oauth";async function xu(){try{let e=await kc.getItem(Tc);return e?JSON.parse(e):null}catch{return null}}async function xc(e){try{await kc.setItem(Tc,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function bn(){try{await kc.removeItem(Tc);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Jf=5,wn=null,_u={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Aa(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:d,collectPaymentMethod:g,createCryptoPaymentToken:k}=useOnramp(),[h,b]=useState(r),[w,c]=useState(!!e?.externalUserId),[S,y]=useState(false),[u,f]=useState(""),[x,_]=useState(null),[T,C]=useState(e?.email??""),[R,B]=useState(e?.phone??""),[E,D]=useState(""),[P,q]=useState("US"),[j,fe]=useState(""),[Ke,De]=useState(""),G=useRef(""),Se=useRef(""),he=useRef(""),[Ie,Ge]=useState(false),[ke,Y]=useState(false),Te=useRef(0),st=useRef(false),We=useRef(false),Ye=useRef(false),Ae=useRef(""),Ee=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),Me=useRef(null),[pe,ee]=useState(_u),[be,pt]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[M,W]=useState(""),[se,oe]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[ve,xt]=useState(e?.defaultSourceAmount??"100"),[ce,ae]=useState(e?.defaultSourceCurrency??"usd"),[ze,Yt]=useState(e?.defaultDestinationCurrency??"usdc"),[mt,de]=useState(null),[et,xr]=useState(),[_t,io]=useState(),[Or,ir]=useState(false),$t=useRef(null),xe=useRef(false),at=useRef(0),N=useRef(e?.onComplete),re=useRef(e?.onError),_e=useRef(e?.onStepChange),ue=useRef(r);useEffect(()=>{N.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{re.current=e?.onError;},[e?.onError]),useEffect(()=>{_e.current=e?.onStepChange;},[e?.onStepChange]);let ne=useRef(r);useEffect(()=>{h!==ne.current&&(_e.current?.(h,ne.current),ne.current=h),ue.current=h;},[h]),useEffect(()=>{w&&h!==r&&c(false);},[w,h,r]);let O=useCallback((I,v,U)=>{let X={code:I,message:v,step:ue.current,stripeErrorCode:U};_(X),f(""),re.current?.(X);},[]),ft=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 N.current?.(v),v},[]),Fe=useCallback(()=>_(null),[]),un=I=>I.refresh_token??I.refresh?.refresh_token??"",Si=useCallback((I,v,U,X,me)=>{Se.current=v,G.current=U,e?.externalUserId&&xc({accessToken:v,refreshToken:U,customerId:I,externalUserId:e.externalUserId,email:me||T,expiresAt:Date.now()+X*1e3});},[e?.externalUserId,T]),ki=useCallback(async()=>{let I=G.current;if(!I)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let v=await bc(I),U=v.access_token,X=un(v)||I;return De(U),Si(he.current,U,X,v.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),U}catch(v){return console.error("[tryRefreshAccessToken] refresh failed:",v?.message),await bn(),wn=null,Se.current="",G.current="",he.current="",De(""),fe(""),null}},[Si]),yo=useCallback(async I=>{try{return await I(Se.current)}catch(v){let U=v?.message??"";if(U.includes("stripe_onramp_forbidden")||U.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let X=await ki();if(!X)throw O("authorization_error","Session expired. Please sign in again."),b("email"),v;return await I(X)}throw v}},[ki,O]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){ir(false);return}let v=false;return isPlatformPaySupported().then(U=>{v||ir(U);}),()=>{v=true;}},[e?.merchantIdentifier]),useEffect(()=>(xe.current=false,()=>{xe.current=true,$t.current&&clearTimeout($t.current);}),[]);let Ti=useRef(false);useEffect(()=>{if(Ti.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),bn(),wn=null,c(false);return}let I=false;return (async()=>{try{let v=await xu();if(I||!v){I||c(!1);return}if(v.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",v.externalUserId,"current:",e.externalUserId),await bn(),wn=null,I||c(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",v.customerId);let U=Date.now()>=v.expiresAt,X=v.accessToken,me=v.refreshToken;if(U){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let He=await bc(v.refreshToken);if(I)return;X=He.access_token,me=He.refresh_token??He.refresh?.refresh_token??v.refreshToken,await xc({accessToken:X,refreshToken:me,customerId:v.customerId,externalUserId:e.externalUserId,email:v.email,expiresAt:Date.now()+(He.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(He){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",He?.message),await bn(),wn=null,I||c(!1);return}}if(I)return;if(Ti.current=!0,fe(v.customerId),he.current=v.customerId,De(X),Se.current=X,G.current=me,v.email&&C(v.email),wn===v.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",v.customerId,"\u2014 skipping configure()"),Me.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",v.customerId);let He=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});He.error?console.error("[useStripeOnramp] restore configureSDK error:",He.error.message):wn=v.customerId,Me.current=Promise.resolve(He);}if(I)return;let lt=()=>new Promise(He=>{let ur=()=>{Ye.current&&Ae.current?He():setTimeout(ur,200);};ur();});try{if(await Promise.race([lt(),new Promise((ur,Vt)=>setTimeout(()=>Vt(new Error("timeout")),1e4))]),I)return;let He=Ae.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",He,"network:",Ee.current),await d(He,Ee.current);}catch(He){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",He?.message);}if(I)return;console.log("[useStripeOnramp] credentials restored, skipping to session_params"),b("session_params");}finally{I||c(false);}})(),()=>{I=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||Ie||ke)return;let I=false;Y(true);async function v(){try{let[U,X]=await Promise.all([ku({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?Tu({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Lt=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Lt?.message),null)):Promise.resolve(null)]);if(I)return;let me=e?.destinationChainType??"ethereum",lt=U.data.find(Lt=>Lt.chain_type===me);if(lt?.address){let Lt=lt.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",Lt,"recipient:",lt.recipient_address),pt(Lt),Ae.current=Lt,lt.recipient_address&&W(lt.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",me,"in",U.data?.length,"wallets");let He={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},ur={8453:"base",1:"ethereum",137:"polygon"},Vt=X?.destination_network,sr="none";if(Vt&&He[Vt])oe(He[Vt]),Ee.current=He[Vt],sr=Vt+" (from default_token API)";else if(e?.destinationChainId&&ur[e.destinationChainId]){let Lt=ur[e.destinationChainId];He[Lt]&&(oe(He[Lt]),Ee.current=He[Lt]),sr=Lt+" (from chain_id "+e.destinationChainId+")";}else He[me]&&(oe(He[me]),Ee.current=He[me],sr=me+" (from chain_type fallback)");X?.destination_currency&&Yt(X.destination_currency.toLowerCase());let er=X?.destination_token_metadata,qr=Sc(er?.icon_urls,er?.icon_url),Qr=Sc(er?.chain?.icon_urls,er?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",qr,"network:",Qr),qr&&xr(qr),Qr&&io(Qr),Ge(!0),Ye.current=!0;}catch(U){console.error("[useStripeOnramp] Failed to resolve wallet:",U?.message),Ge(true),Ye.current=true;}finally{I||Y(false);}}return v(),()=>{I=true;}},[e?.publishableKey,e?.externalUserId]);let so=useCallback(async()=>{if(Me.current)return Me.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),Me.current=null),v)).catch(v=>{throw console.error("[useStripeOnramp] configureSDK threw:",v?.message??v),Me.current=null,v});return Me.current=I,I},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||so();},[]);let Mo=useCallback(async I=>{if(!st.current){st.current=true,y(true),Fe(),f("Creating auth intent...");try{let v=await yc(I);f("Waiting for authorization...");let U=await i(v);if(U?.error){console.log("[proceedToAuthorize] authorize error:",U.error.message),O("authorization_error","Something went wrong during authorization. Please try again."),b("email");return}if(U?.status==="Denied"){O("authorization_error","Authorization denied by user."),b("email");return}if(U?.status!=="Consented"||!U.customerId){O("authorization_error","Authorization was canceled."),b("email");return}f("Exchanging tokens...");let X=await yu(v),me=U.customerId,lt=X.access_token,He=un(X);console.log("[useStripeOnramp] customerId:",me),console.log("[useStripeOnramp] accessToken acquired, length:",lt.length),fe(me),he.current=me,wn=me,De(lt),Si(me,lt,He,X.expires_in??3600),f("Checking verification status...");try{let ur=await Wa(me,lt),Vt=ur.verifications.find(pn=>pn.name==="kyc_verified"),sr=ur.verifications.find(pn=>pn.name==="id_document_verified"),er=Vt?.status==="verified",qr=Vt?.status==="rejected",Qr=sr?.status==="verified",Lt=ur.provided_fields.includes("first_name");if(f(""),qr&&!Lt)O("kyc_error","KYC was previously rejected. Please submit with correct info."),b("kyc");else if(qr&&Lt)b(Qr?"wallet":"identity");else if(!er&&!Lt)b("kyc");else if(!Qr)b("identity");else if(Ye.current&&Ae.current)try{let pn=Ae.current.toLowerCase();console.log("[proceedToAuthorize] registering wallet:",pn,"network:",se);let ua=await d(pn,se);ua?.error?(console.warn("[proceedToAuthorize] wallet registration error:",ua.error.message),O("wallet_error",ua.error.message,ua.error.code),b("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),b("session_params"));}catch(pn){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",pn?.message),b("wallet");}else b("wallet");}catch(ur){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",ur?.message),f(""),b("kyc");}}catch(v){O("authorization_error",v?.message??String(v)),b("email");}finally{st.current=false,y(false);}}},[i,Fe,O,Si,d,se]),$=useCallback(async()=>{if(Keyboard.dismiss(),!T){O("validation_error","Please enter an email address.");return}y(true),Fe(),f("");try{f("Configuring...");let I=await so();if(I.error){O("configuration_error",I.error.message,I.error.code);return}f("Checking Link account...");let v=await n(T);if(v.error){O("authorization_error",v.error.message,v.error.code);return}v.hasLinkAccount?await Mo(T):(f(""),b("register"));}catch(I){O("unknown_error",I?.message??String(I));}finally{y(false);}},[Fe,so,T,O,n,Mo]),ie=useCallback(async()=>{if(!R){O("validation_error","Please enter your phone number.");return}y(true),Fe(),f("");try{f("Creating Link account...");let I=await a({email:T,phone:R,fullName:E||T,country:P||"US"});if(I.error){O("registration_error",I.error.message,I.error.code);return}await Mo(T);}catch(I){O("registration_error",I?.message??String(I));}finally{y(false);}},[Fe,P,T,O,E,R,a,Mo]);useEffect(()=>{if(h!=="email"||!e?.email||w)return;let I=++Te.current,v=false,U=()=>v||Te.current!==I;return e?.phone?(async()=>{y(true),Fe();try{f("Configuring...");let X=await so();if(U())return;if(X.error){O("configuration_error",X.error.message,X.error.code);return}f("Checking Link account...");let me=await n(e.email);if(U())return;if(me.error){O("authorization_error",me.error.message,me.error.code);return}if(me.hasLinkAccount){if(U())return;await Mo(e.email);}else {f("Creating Link account...");let lt=await a({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(U())return;if(lt.error){O("registration_error",lt.error.message,lt.error.code);return}if(U())return;await Mo(e.email);}}catch(X){U()||O("unknown_error",X?.message??String(X));}finally{y(false);}})():(async()=>{y(true),Fe();try{f("Configuring...");let X=await so();if(U())return;if(X.error){O("configuration_error",X.error.message,X.error.code);return}f("Checking Link account...");let me=await n(e.email);if(U())return;if(me.error){O("authorization_error",me.error.message,me.error.code);return}if(me.hasLinkAccount){if(U())return;await Mo(e.email);}else {if(U())return;f(""),b("register");}}catch(X){U()||O("unknown_error",X?.message??String(X));}finally{y(false);}})(),()=>{v=true;}},[h,e?.email,e?.phone,w]);let wt=useCallback(async I=>{y(true),Fe(),f(""),ee(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}},U=await s(v);if(U?.error){if(U.error.stripeErrorCode==="consumer_person_already_verified"){f(""),b("identity");return}O("kyc_error",U.error.message,U.error.stripeErrorCode??U.error.code),b("kyc");return}f("Please review your KYC information...");let X=await l(null);if(X?.error){O("kyc_error",X.error.message,X.error.stripeErrorCode??X.error.code),b("kyc");return}if(X?.status==="UpdateAddress"){O("kyc_error","Please update your address and resubmit."),b("kyc");return}f(""),b("identity");}catch(v){O("kyc_error",v?.message??String(v)),b("kyc");}finally{y(false);}},[s,Fe,O,l]),Dr=useCallback(async()=>{if(!We.current){We.current=true,y(true),Fe(),f("Launching identity verification...");try{let I=await m();if(I?.error){O("identity_error",I.error.message,I.error.code);return}f(""),b("wallet");}catch(I){O("identity_error",I?.message??String(I));}finally{We.current=false,y(false);}}},[Fe,O,m]);useEffect(()=>{h==="identity"&&!S&&Dr();},[h]);let ys=useCallback(async()=>{if(!be){O("validation_error","Please enter a wallet address.");return}y(true),Fe(),f("");try{let I=be.toLowerCase();console.log("[registerWallet] registering wallet:",I,"network:",se);let v=await d(I,se);if(v?.error){console.warn("[registerWallet] error:",v.error.message),O("wallet_error",v.error.message,v.error.code);return}console.log("[registerWallet] wallet registered successfully"),f(""),b("session_params");}catch(I){O("wallet_error",I?.message??String(I));}finally{y(false);}},[Fe,O,be,se,d]);useEffect(()=>{h==="wallet"&&Ie&&be&&ys();},[h,Ie,be]);let ao=useCallback(I=>{xe.current=false,at.current=0;let v=0,U=async()=>{v+=1;let X=Se.current;try{let me=await wu(I,X);if(console.log(`[pollSessionStatus] poll #${v} session=${I} status="${me.status}"`),xe.current)return;at.current=0,me.status==="fulfillment_complete"?(de(me),b("success")):$t.current=setTimeout(U,3e3);}catch(me){if(xe.current)return;let lt=me?.message??"";if((lt.includes("stripe_onramp_forbidden")||lt.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await ki()&&!xe.current)){$t.current=setTimeout(U,1e3);return}if(at.current+=1,console.error(`[pollSessionStatus] poll #${v} error:`,lt),at.current>=Jf){O("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}$t.current=setTimeout(U,5e3);}};$t.current=setTimeout(U,3e3);},[O,ki]),lo=useCallback(()=>{if(ue.current==="processing"&&mt?.id){if(!Se.current){O("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}Fe(),at.current=0,$t.current&&(clearTimeout($t.current),$t.current=null),ao(mt.id);}},[Fe,O,ao,mt?.id]),Fr=useCallback(async I=>{y(true),Fe(),f("");try{f("Confirming purchase...");let v=await yo(U=>Cu(I,U));console.log("[finalizeOnrampSession] confirmed session:",v.id,"status:",v.status),de(v),b("processing"),f(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",v.id),ao(v.id);}finally{y(false);}},[Fe,ao,yo]),zo=useRef(false),Vm=useCallback(async()=>{if(!(!mt||zo.current)){zo.current=true;try{y(!0),Fe(),f("Refreshing quote...");let I=await yo(v=>Cc(mt.id,v));de(I),await Fr(I.id);}catch(I){console.log("[confirmCheckout] error:",I?.message),O("session_error","Something went wrong. Please try again."),b("quote");}finally{y(false),zo.current=false;}}},[Fe,O,Fr,mt,yo]),Md=useCallback(async()=>{let I=T;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 yc(I),U=await i(v);return U?.status==="Consented"&&U.customerId?(console.log("[reauthorizeLink] re-authorized successfully, customerId:",U.customerId),he.current=U.customerId,fe(U.customerId),wn=U.customerId,!0):(console.warn("[reauthorizeLink] authorize did not consent:",U?.status),!1)}catch(v){return console.warn("[reauthorizeLink] failed:",v?.message),false}},[i,T]),Lm=useCallback(async(I=false,v,U)=>{let X=v??ve;if(console.log("[collectPaymentMethod] called:",{useApplePay:I,amt:X,amountOverride:v,sourceAmount:ve,hasSavedToken:!!U}),!X||isNaN(Number(X))||Number(X)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),O("validation_error","Please enter a valid amount.");return}v&&xt(v),y(true),Fe(),f("");try{let me=await so();if(me.error){O("configuration_error",me.error.message,me.error.code);return}let lt;if(U)console.log("[collectPaymentMethod] using saved payment token"),lt=U;else if(I){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),O("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 Vt={applePay:{merchantCountryCode:"US",currencyCode:ce.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${ze.toUpperCase()} purchase + fees`,amount:X}]}},sr=await g("PlatformPay",Vt);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!sr?.error),sr?.error){let qr=sr.error.message??"",Qr=sr.error.code??"",Lt=/cancel/i.test(qr)||/cancel/i.test(Qr);console.log("[collectPaymentMethod] pmResult error:",sr.error,"isCancellation:",Lt),Lt||(O("payment_error",qr,Qr),b("session_params"));return}if(!sr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}f("Creating payment token...");let er=await k();if(console.log("[collectPaymentMethod] tokenResult ok:",!er?.error),er?.error){O("payment_error",er.error.message,er.error.code),b("session_params");return}lt=er.cryptoPaymentToken;}else {f("Select a payment method...");let Vt=await g("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Vt?.error),Vt?.error){let qr=Vt.error.message??"",Qr=Vt.error.code??"",Lt=/cancel/i.test(qr)||/cancel/i.test(Qr);console.log("[collectPaymentMethod] pmResult error:",Vt.error,"isCancellation:",Lt),Lt||(O("payment_error",qr,Qr),b("session_params"));return}if(!Vt?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let sr=Vt.displayData;console.log("[collectPaymentMethod] displayData:",{type:sr.type,label:sr.label,sublabel:sr.sublabel,hasIcon:!!sr.icon}),f("Creating payment token...");let er=await k();if(console.log("[collectPaymentMethod] tokenResult ok:",!er?.error),er?.error){O("payment_error",er.error.message,er.error.code),b("session_params");return}lt=er.cryptoPaymentToken;}f("Creating onramp session..."),console.log("[collectPaymentMethod] creating onramp session, walletAddress:",be,"walletAddressRef:",Ae.current);let He=Ae.current||be.toLowerCase(),ur=await yo(Vt=>bu({cryptoCustomerId:he.current,paymentToken:lt,sourceAmount:Number(X),sourceCurrency:ce,destinationCurrency:ze,walletAddress:He,destinationNetwork:se},Vt));console.log("[collectPaymentMethod] session created:",ur?.id,"useApplePay:",I),de(ur),f(""),I?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await Fr(ur.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):b("quote");}catch(me){console.log("[collectPaymentMethod] error caught:",me?.message),O("session_error","Something went wrong. Please try again."),b("session_params");}finally{y(false),f("");}},[Fe,so,g,k,ze,O,Fr,xt,ve,ce,be,se,yo,e?.merchantIdentifier]),Bm=useCallback(async()=>{y(true),Fe(),f("Select a payment method...");try{let I=await so();if(I.error)return O("configuration_error",I.error.message,I.error.code),null;let v=await g("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 Md())return O("authorization_error","Please verify your identity to add a payment method."),null;v=await g("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!v?.error);}if(v?.error){let me=v.error.message??"",lt=v.error.code??"",He=/cancel/i.test(me)||/cancel/i.test(lt);return console.log("[addPaymentMethod] pmResult error:",v.error,"isCancellation:",He),He||O("payment_error",me,lt),null}if(!v?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let U=v.displayData;console.log("[addPaymentMethod] displayData:",{type:U.type,label:U.label,sublabel:U.sublabel,hasIcon:!!U.icon}),f("Saving payment method...");let X=await k();return console.log("[addPaymentMethod] tokenResult ok:",!X?.error),X?.error?(O("payment_error",X.error.message,X.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:X.cryptoPaymentToken,sublabel:U.sublabel??""})}catch(I){return console.log("[addPaymentMethod] error:",I?.message),O("session_error",I?.message??String(I)),null}finally{y(false),f("");}},[Fe,so,g,k,O,Md]),Wm=useCallback(async()=>{if(mt){y(true),Fe(),f("");try{let I=await yo(v=>Cc(mt.id,v));de(I);}catch(I){console.log("[refreshQuote] error:",I?.message),O("session_error","Something went wrong. Please try again.");}finally{y(false);}}},[Fe,O,mt,yo]),Am=useCallback(()=>{xe.current=true,at.current=0,$t.current&&(clearTimeout($t.current),$t.current=null),b(r),y(false),f(""),_(null),C(e?.email??""),B(e?.phone??""),D(""),q("US"),fe(""),he.current="",De(""),Se.current="",G.current="",Ge(false),Y(false),ee(_u),pt(e?.recipientAddress??""),Ae.current="",Ye.current=false,oe(Onramp.CryptoNetwork.ethereum),xt(e?.defaultSourceAmount??"100"),ae(e?.defaultSourceCurrency??"usd"),Yt(e?.defaultDestinationCurrency??"usdc"),W(""),xr(void 0),io(void 0),de(null),Te.current+=1,st.current=false,We.current=false;},[e,r]);return {step:h,restoring:w,loading:S,status:u,error:x,email:T,phone:R,fullName:E,country:P,customerId:j,accessToken:Ke,session:mt,kycData:pe,walletAddress:be,resolvedRecipientAddress:M,walletNetwork:se,sourceAmount:ve,sourceCurrency:ce,destinationCurrency:ze,tokenIconUrl:et,networkIconUrl:_t,applePaySupported:Or,walletReady:Ie,walletLoading:ke,setStep:b,setStatus:f,setEmail:C,setPhone:B,setFullName:D,setCountry:q,setWalletAddress:pt,setWalletNetwork:oe,setSourceAmount:xt,setSourceCurrency:ae,setDestinationCurrency:Yt,checkEmail:$,register:ie,attachKyc:wt,verifyIdentity:Dr,registerWallet:ys,collectPaymentMethod:Lm,addPaymentMethod:Bm,refreshQuote:Wm,confirmCheckout:Vm,reset:Am,clearError:Fe,emitComplete:ft,resumeFulfillmentPolling:lo,amountFirst:t}}function Ru({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(Jt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(ht,{size:56,strokeWidth:3}),jsx(wr,{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(Jt,{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(ht,{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(wr,{error:n,progress:a,loading:o})]})]})})}function vu({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:a}){return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:a}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(ht,{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(wr,{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 Ou({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,onClose:m,onRetryStatusCheck:d}){let g=!!t;return jsxs(View,{style:e.form.screen,children:[g?jsx(Jt,{onPress:m}):jsx(View,{style:va}),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(ht,{size:48,strokeWidth:3})}),jsx(Text,{style:e.flow.heading,children:"Processing your purchase"}),jsxs(Text,{style:e.flow.sub,children:["Your payment has been confirmed.",`
2
- `,"We're sending your crypto \u2014 this usually takes less than a minute."]}),n&&a&&i&&jsx(Oa,{sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(wr,{error:t,progress:r,loading:o}),t?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:d,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function Du({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:a,tokenIconUrl:i,networkIconUrl:s,onClose:l,onBack:m}){let d=t.transaction_details,g=Ra(d.destination_amount,d.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{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(lu,{currency:d.destination_currency,tokenIconUrl:i,networkIconUrl:s,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(co,{quote:e.quote,label:"You pay",value:`${d.source_amount} ${d.source_currency.toUpperCase()}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"You receive",value:`${g} ${d.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"Network fee",value:`$${d.fees.network_fee_amount}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"Transaction fee",value:`$${d.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(ht,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:a,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(wr,{error:o,progress:n,loading:r})]})]})}function Fu({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:a,phone:i,setPhone:s,register:l,onClose:m}){let d=V();return t?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(ht,{size:56,strokeWidth:3}),jsx(wr,{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(Jt,{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:d.components.input.placeholderColor,keyboardType:"phone-pad",value:i,onChangeText:g=>s(g.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(ht,{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(wr,{error:o,progress:n,loading:r})]})]})})}function mh({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=V(),n=e.toLowerCase(),a=Pa[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:[xo.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:a}],children:jsx(Text,{style:[xo.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[xo.checkBadge,{width:i,height:i,borderRadius:i/2,backgroundColor:o.success,borderColor:o.background}],children:jsx(qe,{size:i*.55,color:"#FFFFFF",strokeWidth:3})})]})}function Vu({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:a,onDone:i}){let {colors:s,components:l,fonts:m}=V(),d=t.transaction_details,g=Ra(d.destination_amount,d.destination_currency),k=r||o||"";Ia(d.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:i,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(BottomSheetScrollView,{style:e.form.flex,contentContainerStyle:xo.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:xo.iconSection,children:[jsx(mh,{currency:d.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:xo.statusRow,children:[jsx(View,{style:[xo.statusDot,{backgroundColor:s.success}]}),jsx(Text,{style:[xo.statusText,{color:s.foreground,fontFamily:m.semibold}],children:"Completed"})]}),jsx(Text,{style:[xo.subtitle,{color:s.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(Oa,{sourceCurrency:d.source_currency,destinationCurrency:d.destination_currency,destinationNetwork:d.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},xo.detailCard],children:[jsx(co,{quote:e.quote,label:"You Bought",value:`${d.source_amount} ${d.source_currency.toUpperCase()}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"You Received",value:`${g} ${d.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"Network Fee",value:`$${d.fees.network_fee_amount}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"Transaction Fee",value:`$${d.fees.transaction_fee_amount}`,hideDivider:true}),jsx(dc,{quote:e.quote,label:"Intent Address",address:d.wallet_address,hideDivider:true}),k?jsx(dc,{quote:e.quote,label:"Recipient Address",address:k,last:true}):jsx(co,{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 xo=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 Lu({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:a,walletNetwork:i,setWalletAddress:s,setWalletNetwork:l,setDestinationCurrency:m,registerWallet:d,onClose:g}){let{components:k}=V();if(t){let h=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:g}),jsxs(View,{style:e.flow.centered,children:[!h&&jsx(ht,{size:56,strokeWidth:3}),jsx(wr,{error:o,progress:n,loading:r})]}),h&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:d,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(Jt,{onPress:g}),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:k.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:_a.map(h=>{let b=i===h.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,b&&e.wallet.rowSelected],onPress:()=>{l(h.value),m(h.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(h.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,b&&e.wallet.rowTextSelected],children:h.label}),b&&jsx(View,{style:e.wallet.checkCircle,children:jsx(qe,{size:14,color:k.container.buttonTitleColor,strokeWidth:2.5})})]},h.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(ht,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!a&&e.form.continueBtnDisabled],onPress:d,disabled:!a,children:jsx(Text,{style:[e.form.continueBtnText,!a&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(wr,{error:o,progress:n,loading:r})]})]})})}function Ha({config:e,onClose:t}){let r=V(),o=Li(),{step:n,restoring:a,loading:i,status:s,error:l,email:m,phone:d,session:g,kycData:k,walletAddress:h,resolvedRecipientAddress:b,walletNetwork:w,sourceAmount:c,sourceCurrency:S,destinationCurrency:y,tokenIconUrl:u,networkIconUrl:f,applePaySupported:x,setStep:_,setEmail:T,setPhone:C,setWalletAddress:R,setWalletNetwork:B,setSourceAmount:E,setDestinationCurrency:D,checkEmail:P,register:q,attachKyc:j,verifyIdentity:fe,registerWallet:Ke,collectPaymentMethod:De,addPaymentMethod:G,confirmCheckout:Se,reset:he,emitComplete:Ie,resumeFulfillmentPolling:Ge,amountFirst:ke,customerId:Y,accessToken:Te}=Aa(e),st=!!e?.email,We=!!e?.phone,Ye=!!e?.publishableKey&&!!e?.externalUserId,[Ae,Ee]=useState(void 0),[Me,pe]=useState([]);useEffect(()=>{if(n!=="session_params"||!Y||!Te)return;console.log("[OnrampScreen] customerId:",Y);let W=oe=>{let ve=oe?.message??"";return ve.includes("stripe_onramp_forbidden")||ve.includes("403")},se=oe=>{W(oe)&&(bn(),he());};Wa(Y,Te).then(oe=>{console.log("[OnrampScreen] customer fetched, id:",oe?.id);}).catch(oe=>{console.warn("[OnrampScreen] customer fetch error:",oe?.message),se(oe);}),wc(Y,Te).then(oe=>{console.log("[OnrampScreen] payment_tokens fetched, count:",oe.data?.length??0),pe(oe.data??[]);}).catch(oe=>{console.warn("[OnrampScreen] payment_tokens error:",oe?.message),se(oe);}),console.log("[OnrampScreen] walletAddress:",h,"walletNetwork:",w),h&&(console.log("[OnrampScreen] calling getTransactionLimits..."),Su({destinationNetwork:w||"ethereum",walletAddress:h,accessToken:Te,cryptoCustomerId:Y}).then(oe=>{console.log("[OnrampScreen] transaction_limits fetched");let ve=oe.limits?.usd;if(ve?.card?.length){let xt=Math.max(...ve.card.map(ce=>ce.limit));Ee(xt),console.log("[OnrampScreen] card max amount:",xt);}}).catch(oe=>{console.warn("[OnrampScreen] transaction_limits error:",oe?.message),se(oe);}));},[n,Y,Te,h,w,he]);let ee=async()=>{if(!(!Y||!Te))try{let W=await wc(Y,Te);console.log("[OnrampScreen] payment_tokens refreshed, count:",W.data?.length??0),pe(W.data??[]);}catch(W){console.warn("[OnrampScreen] payment_tokens refresh error:",W?.message);let se=W?.message??"";(se.includes("stripe_onramp_forbidden")||se.includes("403"))&&(bn(),he());}},be=async()=>{let W=await G();return W&&await ee(),W},pt=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&pt&&g&&(Ie(g),he(),t?.());},[n,pt,g,Ie,he,t]);let M=()=>{he(),t?.();};return a?jsx(View,{style:Ch.container,children:jsx(ht,{size:56,strokeWidth:3})}):n==="email"?jsx(Ru,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:st,loading:i,error:l,status:s,email:m,setEmail:T,checkEmail:P,onClose:M}):n==="register"?jsx(Fu,{styles:o,hasPrefilledPhone:We,loading:i,error:l,status:s,email:m,phone:d,setPhone:C,register:q,onClose:M}):n==="kyc"?jsx(Fa,{initialData:k,loading:i,onComplete:j,onCancel:()=>_("email")}):n==="identity"?jsx(vu,{styles:o,loading:i,status:s,error:l,verifyIdentity:fe,onClose:M}):n==="wallet"?jsx(Lu,{styles:o,hasAutoWallet:Ye,loading:i,error:l,status:s,walletAddress:h,walletNetwork:w,setWalletAddress:R,setWalletNetwork:B,setDestinationCurrency:D,registerWallet:Ke,onClose:M}):n==="session_params"?jsx(Da,{initialAmount:c,currency:S,applePaySupported:x,paymentSelectorPosition:e?.paymentSelectorPosition??"header",maxAmount:Ae,paymentTokens:Me,onAddPaymentMethod:be,onCollectPayment:(W,se)=>{De(W,se);},paymentLoading:i,paymentStatus:s,paymentError:l?.message??null,onConfirm:(W,se)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:W,selectedMethod:se,amountFirst:ke}),ke&&!Y)E(W),_("email");else {let oe=se==="apple_pay",ve=!oe&&se?se:void 0;console.log("[OnrampScreen] isApplePay:",oe,"hasSavedToken:",!!ve),De(oe,W,ve);}},onCancel:M}):n==="quote"&&g?jsx(Du,{styles:o,session:g,loading:i,error:l,status:s,confirmCheckout:Se,tokenIconUrl:u,networkIconUrl:f,onClose:M,onBack:()=>_("session_params")}):n==="processing"?jsx(Ou,{styles:o,error:l,status:s,loading:i,sourceCurrency:g?.transaction_details.source_currency,destinationCurrency:g?.transaction_details.destination_currency??y,destinationNetwork:g?.transaction_details.destination_network??"base",tokenIconUrl:u,networkIconUrl:f,onClose:M,onRetryStatusCheck:Ge}):n==="success"&&g&&!pt?jsx(Vu,{styles:o,session:g,resolvedRecipientAddress:b,recipientFromConfig:e?.recipientAddress,tokenIconUrl:u,networkIconUrl:f,onDone:()=>{Ie(g),he(),t?.();}}):null}var Ch=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000"}});function Au(){try{let e=wh.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 Na({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:a="ethereum",destinationChainId:i="8453",destinationTokenAddress:s,recipientAddress:l,onComplete:m,onError:d,onStepChange:g,onClose:k,merchantIdentifier:h="",urlScheme:b="unifoldOnramp",paymentSelectorPosition:w,skipSuccessConfirmation:c=false}){let S=e||Ca(),y=useMemo(()=>{let C=h.trim();return C.length>0?C:Au()??""},[h]),[u,f]=useState("loading"),[x,_]=useState(null);useEffect(()=>{let C=false;async function R(){try{S&&(Va(S),La(_s()));let B=await Ba();if(C)return;let E=y.trim();if(await initStripe({publishableKey:B,urlScheme:b,...E?{merchantIdentifier:E}:{}}),C)return;f("ready");}catch(B){if(C)return;console.error("[StripeOnramp] Init failed:",B),_(B?.message??"Failed to load Stripe configuration"),f("error");}}return R(),()=>{C=true;}},[S,y,b]);let T=useMemo(()=>{let C={publishableKey:S,externalUserId:o,destinationChainType:a,destinationChainId:i,onComplete:m,onError:d,onStepChange:g};return s&&(C.destinationTokenAddress=s),l&&(C.recipientAddress=l),t&&(C.email=t),r&&(C.phone=r),n&&(C.flowOrder=n),w&&(C.paymentSelectorPosition=w),C.skipSuccessConfirmation=c,C.merchantIdentifier=y,C},[S,o,a,i,s,l,t,r,n,w,c,y,m,d,g]);return u==="error"?jsxs(View,{style:Mi.centered,children:[jsx(Text,{style:Mi.errorText,children:"Unable to initialize"}),jsx(Text,{style:Mi.errorDetail,children:x}),k&&jsx(TouchableOpacity,{style:Mi.retryBtn,onPress:k,children:jsx(Text,{style:Mi.retryBtnText,children:"Go Back"})})]}):u==="loading"?jsx(View,{style:Mi.centered,children:jsx(ht,{size:56,strokeWidth:3})}):jsx(Ha,{config:T,onClose:k})}var Mi=StyleSheet.create({centered:{flex:1,justifyContent:"center",alignItems:"center",backgroundColor:"#000000",paddingHorizontal:24},errorText:{color:"#FF453A",fontSize:18,fontWeight:"600",marginBottom:8},errorDetail:{color:"#8E8E93",fontSize:14,textAlign:"center",marginBottom:24},retryBtn:{backgroundColor:"#00D924",borderRadius:24,paddingVertical:14,paddingHorizontal:32},retryBtnText:{color:"#000000",fontSize:16,fontWeight:"700"}});function Uu(){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 Hu="__unifold_stripe_onramp__";function ja(e){globalThis[Hu]=e;}function Nu(){return globalThis[Hu]}ja(Na);var _o=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 Yn,Tn,zi,ju,Ph=(ju=class extends _o{constructor(){super();J(this,Yn);J(this,Tn);J(this,zi);L(this,zi,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){p(this,Tn)||this.setEventListener(p(this,zi));}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,Tn))==null||t.call(this),L(this,Tn,void 0));}setEventListener(t){var r;L(this,zi,t),(r=p(this,Tn))==null||r.call(this),L(this,Tn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){p(this,Yn)!==t&&(L(this,Yn,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof p(this,Yn)=="boolean"?p(this,Yn):globalThis.document?.visibilityState!=="hidden"}},Yn=new WeakMap,Tn=new WeakMap,zi=new WeakMap,ju),Ui=new Ph;var Oh={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ro,Jn,$u,Dh=($u=class{constructor(){J(this,Ro,Oh);J(this,Jn,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&p(this,Jn)&&e!==p(this,Ro)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:p(this,Ro),provider:e}),L(this,Ro,e),process.env.NODE_ENV!=="production"&&L(this,Jn,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&L(this,Jn,true),p(this,Ro).setTimeout(e,t)}clearTimeout(e){p(this,Ro).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&L(this,Jn,true),p(this,Ro).setInterval(e,t)}clearInterval(e){p(this,Ro).clearInterval(e);}},Ro=new WeakMap,Jn=new WeakMap,$u),Io=new Dh;function qu(e){setTimeout(e,0);}var vc=typeof window>"u"||"Deno"in globalThis;function Kt(){}function Gu(e,t){return typeof e=="function"?e(t):e}function As(e){return typeof e=="number"&&e>=0&&e!==1/0}function qa(e,t){return Math.max(e+(t||0)-Date.now(),0)}function mo(e,t){return typeof e=="function"?e(t):e}function Rr(e,t){return typeof e=="function"?e(t):e}function Qa(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:a,queryKey:i,stale:s}=e;if(i){if(o){if(t.queryHash!==Es(i,t.options))return false}else if(!ei(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 Ka(e,t){let{exact:r,status:o,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return false;if(r){if(Zn(t.options.mutationKey)!==Zn(a))return false}else if(!ei(t.options.mutationKey,a))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Es(e,t){return (t?.queryKeyHashFn||Zn)(e)}function Zn(e){return JSON.stringify(e,(t,r)=>Ic(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function ei(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>ei(e[r],t[r])):false}var Fh=Object.prototype.hasOwnProperty;function $a(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=Qu(e)&&Qu(t);if(!o&&!(Ic(e)&&Ic(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 d=0;d<s;d++){let g=o?d:i[d],k=e[g],h=t[g];if(k===h){l[g]=k,(o?d<a:Fh.call(e,g))&&m++;continue}if(k===null||h===null||typeof k!="object"||typeof h!="object"){l[g]=h;continue}let b=$a(k,h,r+1);l[g]=b,b===k&&m++;}return a===s&&m===a?e:l}function Ga(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 Qu(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function Ic(e){if(!Ku(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!Ku(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Ku(e){return Object.prototype.toString.call(e)==="[object Object]"}function Yu(e){return new Promise(t=>{Io.setTimeout(t,e);})}function Ms(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 $a(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 $a(e,t)}return t}function Ju(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function Zu(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var Xn=Symbol();function Ya(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Xn&&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===Xn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ja(e,t){return typeof e=="function"?e(...t):!!e}function Xu(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 vo=(()=>{let e=()=>vc;return {isServer(){return e()},setIsServer(t){e=t;}}})();function zs(){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 ep=qu;function Vh(){let e=[],t=0,r=s=>{s();},o=s=>{s();},n=ep,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 St=Vh();var Hi,xn,Ni,tp,Lh=(tp=class extends _o{constructor(){super();J(this,Hi,true);J(this,xn);J(this,Ni);L(this,Ni,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(){p(this,xn)||this.setEventListener(p(this,Ni));}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,xn))==null||t.call(this),L(this,xn,void 0));}setEventListener(t){var r;L(this,Ni,t),(r=p(this,xn))==null||r.call(this),L(this,xn,t(this.setOnline.bind(this)));}setOnline(t){p(this,Hi)!==t&&(L(this,Hi,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return p(this,Hi)}},Hi=new WeakMap,xn=new WeakMap,Ni=new WeakMap,tp),ji=new Lh;function Bh(e){return Math.min(1e3*2**e,3e4)}function Pc(e){return (e??"online")==="online"?ji.isOnline():true}var Za=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function Xa(e){let t=false,r=0,o,n=zs(),a=()=>n.status!=="pending",i=w=>{if(!a()){let c=new Za(w);k(c),e.onCancel?.(c);}},s=()=>{t=true;},l=()=>{t=false;},m=()=>Ui.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),d=()=>Pc(e.networkMode)&&e.canRun(),g=w=>{a()||(o?.(),n.resolve(w));},k=w=>{a()||(o?.(),n.reject(w));},h=()=>new Promise(w=>{o=c=>{(a()||m())&&w(c);},e.onPause?.();}).then(()=>{o=void 0,a()||e.onContinue?.();}),b=()=>{if(a())return;let w,c=r===0?e.initialPromise:void 0;try{w=c??e.fn();}catch(S){w=Promise.reject(S);}Promise.resolve(w).then(g).catch(S=>{if(a())return;let y=e.retry??(vo.isServer()?0:3),u=e.retryDelay??Bh,f=typeof u=="function"?u(r,S):u,x=y===true||typeof y=="number"&&r<y||typeof y=="function"&&y(r,S);if(t||!x){k(S);return}r++,e.onFail?.(r,S),Yu(f).then(()=>m()?void 0:h()).then(()=>{t?k(S):b();});});};return {promise:n,status:()=>n.status,cancel:i,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:d,start:()=>(d()?b():h().then(b),n)}}var ti,rp,el=(rp=class{constructor(){J(this,ti);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),As(this.gcTime)&&L(this,ti,Io.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(vo.isServer()?1/0:300*1e3));}clearGcTimeout(){p(this,ti)!==void 0&&(Io.clearTimeout(p(this,ti)),L(this,ti,void 0));}},ti=new WeakMap,rp);var ri,$i,to,oi,rr,Us,ni,Hr,ap,Qo,ip,sp=(ip=class extends el{constructor(t){super();J(this,Hr);J(this,ri);J(this,$i);J(this,to);J(this,oi);J(this,rr);J(this,Us);J(this,ni);L(this,ni,false),L(this,Us,t.defaultOptions),this.setOptions(t.options),this.observers=[],L(this,oi,t.client),L(this,to,p(this,oi).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,L(this,ri,np(this.options)),this.state=t.state??p(this,ri),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return p(this,rr)?.promise}setOptions(t){if(this.options={...p(this,Us),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=np(this.options);r.data!==void 0&&(this.setState(op(r.data,r.dataUpdatedAt)),L(this,ri,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&p(this,to).remove(this);}setData(t,r){let o=Ms(this.state.data,t,this.options);return Le(this,Hr,Qo).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Le(this,Hr,Qo).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=p(this,rr)?.promise;return p(this,rr)?.cancel(t),r?r.then(Kt).catch(Kt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return p(this,ri)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Rr(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Xn||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>mo(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:!qa(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),p(this,rr)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),p(this,rr)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),p(this,to).notify({type:"observerAdded",query:this,observer:t}));}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(p(this,rr)&&(p(this,ni)||Le(this,Hr,ap).call(this)?p(this,rr).cancel({revert:true}):p(this,rr).cancelRetry()),this.scheduleGc()),p(this,to).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Le(this,Hr,Qo).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&p(this,rr)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(p(this,rr))return p(this,rr).continueRetry(),p(this,rr).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:()=>(L(this,ni,true),o.signal)});},a=()=>{let l=Ya(this.options,r),d=(()=>{let g={client:p(this,oi),queryKey:this.queryKey,meta:this.meta};return n(g),g})();return L(this,ni,false),this.options.persister?this.options.persister(l,d,this):l(d)},s=(()=>{let l={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:p(this,oi),state:this.state,fetchFn:a};return n(l),l})();this.options.behavior?.onFetch(s,this),L(this,$i,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&Le(this,Hr,Qo).call(this,{type:"fetch",meta:s.fetchOptions?.meta}),L(this,rr,Xa({initialPromise:r?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof Za&&l.revert&&this.setState({...p(this,$i),fetchStatus:"idle"}),o.abort();},onFail:(l,m)=>{Le(this,Hr,Qo).call(this,{type:"failed",failureCount:l,error:m});},onPause:()=>{Le(this,Hr,Qo).call(this,{type:"pause"});},onContinue:()=>{Le(this,Hr,Qo).call(this,{type:"continue"});},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>true}));try{let l=await p(this,rr).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),p(this,to).config.onSuccess?.(l,this),p(this,to).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof Za){if(l.silent)return p(this,rr).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Le(this,Hr,Qo).call(this,{type:"error",error:l}),p(this,to).config.onError?.(l,this),p(this,to).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},ri=new WeakMap,$i=new WeakMap,to=new WeakMap,oi=new WeakMap,rr=new WeakMap,Us=new WeakMap,ni=new WeakMap,Hr=new WeakSet,ap=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Qo=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,...Oc(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...op(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return L(this,$i,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),St.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),p(this,to).notify({query:this,type:"updated",action:t});});},ip);function Oc(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Pc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function op(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function np(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 Ir,Ne,Ns,Sr,ii,qi,Ko,_n,js,Qi,Ki,si,ai,Rn,Gi,ot,Hs,Dc,Fc,Vc,Lc,Bc,Wc,Ac,up,dp,Mc=(dp=class extends _o{constructor(t,r){super();J(this,ot);J(this,Ir);J(this,Ne);J(this,Ns);J(this,Sr);J(this,ii);J(this,qi);J(this,Ko);J(this,_n);J(this,js);J(this,Qi);J(this,Ki);J(this,si);J(this,ai);J(this,Rn);J(this,Gi,new Set);this.options=r,L(this,Ir,t),L(this,_n,null),L(this,Ko,zs()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(p(this,Ne).addObserver(this),lp(p(this,Ne),this.options)?Le(this,ot,Hs).call(this):this.updateResult(),Le(this,ot,Lc).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Ec(p(this,Ne),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ec(p(this,Ne),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Le(this,ot,Bc).call(this),Le(this,ot,Wc).call(this),p(this,Ne).removeObserver(this);}setOptions(t){let r=this.options,o=p(this,Ne);if(this.options=p(this,Ir).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Rr(this.options.enabled,p(this,Ne))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Le(this,ot,Ac).call(this),p(this,Ne).setOptions(this.options),r._defaulted&&!Ga(this.options,r)&&p(this,Ir).getQueryCache().notify({type:"observerOptionsUpdated",query:p(this,Ne),observer:this});let n=this.hasListeners();n&&cp(p(this,Ne),o,this.options,r)&&Le(this,ot,Hs).call(this),this.updateResult(),n&&(p(this,Ne)!==o||Rr(this.options.enabled,p(this,Ne))!==Rr(r.enabled,p(this,Ne))||mo(this.options.staleTime,p(this,Ne))!==mo(r.staleTime,p(this,Ne)))&&Le(this,ot,Dc).call(this);let a=Le(this,ot,Fc).call(this);n&&(p(this,Ne)!==o||Rr(this.options.enabled,p(this,Ne))!==Rr(r.enabled,p(this,Ne))||a!==p(this,Rn))&&Le(this,ot,Vc).call(this,a);}getOptimisticResult(t){let r=p(this,Ir).getQueryCache().build(p(this,Ir),t),o=this.createResult(r,t);return Ah(this,o)&&(L(this,Sr,o),L(this,qi,this.options),L(this,ii,p(this,Ne).state)),o}getCurrentResult(){return p(this,Sr)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&p(this,Ko).status==="pending"&&p(this,Ko).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){p(this,Gi).add(t);}getCurrentQuery(){return p(this,Ne)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=p(this,Ir).defaultQueryOptions(t),o=p(this,Ir).getQueryCache().build(p(this,Ir),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Le(this,ot,Hs).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),p(this,Sr)))}createResult(t,r){let o=p(this,Ne),n=this.options,a=p(this,Sr),i=p(this,ii),s=p(this,qi),m=t!==o?t.state:p(this,Ns),{state:d}=t,g={...d},k=false,h;if(r._optimisticResults){let R=this.hasListeners(),B=!R&&lp(t,r),E=R&&cp(t,o,r,n);(B||E)&&(g={...g,...Oc(d.data,t.options)}),r._optimisticResults==="isRestoring"&&(g.fetchStatus="idle");}let{error:b,errorUpdatedAt:w,status:c}=g;h=g.data;let S=false;if(r.placeholderData!==void 0&&h===void 0&&c==="pending"){let R;a?.isPlaceholderData&&r.placeholderData===s?.placeholderData?(R=a.data,S=true):R=typeof r.placeholderData=="function"?r.placeholderData(p(this,Ki)?.state.data,p(this,Ki)):r.placeholderData,R!==void 0&&(c="success",h=Ms(a?.data,R,r),k=true);}if(r.select&&h!==void 0&&!S)if(a&&h===i?.data&&r.select===p(this,js))h=p(this,Qi);else try{L(this,js,r.select),h=r.select(h),h=Ms(a?.data,h,r),L(this,Qi,h),L(this,_n,null);}catch(R){L(this,_n,R);}p(this,_n)&&(b=p(this,_n),h=p(this,Qi),w=Date.now(),c="error");let y=g.fetchStatus==="fetching",u=c==="pending",f=c==="error",x=u&&y,_=h!==void 0,C={status:c,fetchStatus:g.fetchStatus,isPending:u,isSuccess:c==="success",isError:f,isInitialLoading:x,isLoading:x,data:h,dataUpdatedAt:g.dataUpdatedAt,error:b,errorUpdatedAt:w,failureCount:g.fetchFailureCount,failureReason:g.fetchFailureReason,errorUpdateCount:g.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:g.dataUpdateCount>m.dataUpdateCount||g.errorUpdateCount>m.errorUpdateCount,isFetching:y,isRefetching:y&&!u,isLoadingError:f&&!_,isPaused:g.fetchStatus==="paused",isPlaceholderData:k,isRefetchError:f&&_,isStale:zc(t,r),refetch:this.refetch,promise:p(this,Ko),isEnabled:Rr(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let R=C.data!==void 0,B=C.status==="error"&&!R,E=q=>{B?q.reject(C.error):R&&q.resolve(C.data);},D=()=>{let q=L(this,Ko,C.promise=zs());E(q);},P=p(this,Ko);switch(P.status){case "pending":t.queryHash===o.queryHash&&E(P);break;case "fulfilled":(B||C.data!==P.value)&&D();break;case "rejected":(!B||C.error!==P.reason)&&D();break}}return C}updateResult(){let t=p(this,Sr),r=this.createResult(p(this,Ne),this.options);if(L(this,ii,p(this,Ne).state),L(this,qi,this.options),p(this,ii).data!==void 0&&L(this,Ki,p(this,Ne)),Ga(r,t))return;L(this,Sr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!p(this,Gi).size)return true;let i=new Set(a??p(this,Gi));return this.options.throwOnError&&i.add("error"),Object.keys(p(this,Sr)).some(s=>{let l=s;return p(this,Sr)[l]!==t[l]&&i.has(l)})};Le(this,ot,up).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Le(this,ot,Lc).call(this);}},Ir=new WeakMap,Ne=new WeakMap,Ns=new WeakMap,Sr=new WeakMap,ii=new WeakMap,qi=new WeakMap,Ko=new WeakMap,_n=new WeakMap,js=new WeakMap,Qi=new WeakMap,Ki=new WeakMap,si=new WeakMap,ai=new WeakMap,Rn=new WeakMap,Gi=new WeakMap,ot=new WeakSet,Hs=function(t){Le(this,ot,Ac).call(this);let r=p(this,Ne).fetch(this.options,t);return t?.throwOnError||(r=r.catch(Kt)),r},Dc=function(){Le(this,ot,Bc).call(this);let t=mo(this.options.staleTime,p(this,Ne));if(vo.isServer()||p(this,Sr).isStale||!As(t))return;let o=qa(p(this,Sr).dataUpdatedAt,t)+1;L(this,si,Io.setTimeout(()=>{p(this,Sr).isStale||this.updateResult();},o));},Fc=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(p(this,Ne)):this.options.refetchInterval)??false},Vc=function(t){Le(this,ot,Wc).call(this),L(this,Rn,t),!(vo.isServer()||Rr(this.options.enabled,p(this,Ne))===false||!As(p(this,Rn))||p(this,Rn)===0)&&L(this,ai,Io.setInterval(()=>{(this.options.refetchIntervalInBackground||Ui.isFocused())&&Le(this,ot,Hs).call(this);},p(this,Rn)));},Lc=function(){Le(this,ot,Dc).call(this),Le(this,ot,Vc).call(this,Le(this,ot,Fc).call(this));},Bc=function(){p(this,si)!==void 0&&(Io.clearTimeout(p(this,si)),L(this,si,void 0));},Wc=function(){p(this,ai)!==void 0&&(Io.clearInterval(p(this,ai)),L(this,ai,void 0));},Ac=function(){let t=p(this,Ir).getQueryCache().build(p(this,Ir),this.options);if(t===p(this,Ne))return;let r=p(this,Ne);L(this,Ne,t),L(this,Ns,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},up=function(t){St.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(p(this,Sr));}),p(this,Ir).getQueryCache().notify({query:p(this,Ne),type:"observerResultsUpdated"});});},dp);function Wh(e,t){return Rr(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function lp(e,t){return Wh(e,t)||e.state.data!==void 0&&Ec(e,t,t.refetchOnMount)}function Ec(e,t,r){if(Rr(t.enabled,e)!==false&&mo(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&zc(e,t)}return false}function cp(e,t,r,o){return (e!==t||Rr(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&zc(e,r)}function zc(e,t){return Rr(t.enabled,e)!==false&&e.isStaleByTime(mo(t.staleTime,e))}function Ah(e,t){return !Ga(e.getCurrentResult(),t)}function Uc(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 d=false,g=b=>{Xu(b,()=>t.signal,()=>d=true);},k=Ya(t.options,t.fetchOptions),h=async(b,w,c)=>{if(d)return Promise.reject();if(w==null&&b.pages.length)return Promise.resolve(b);let y=(()=>{let _={client:t.client,queryKey:t.queryKey,pageParam:w,direction:c?"backward":"forward",meta:t.options.meta};return g(_),_})(),u=await k(y),{maxPages:f}=t.options,x=c?Zu:Ju;return {pages:x(b.pages,u,f),pageParams:x(b.pageParams,w,f)}};if(n&&a.length){let b=n==="backward",w=b?Eh:pp,c={pages:a,pageParams:i},S=w(o,c);s=await h(c,S,b);}else {let b=e??a.length;do{let w=l===0?i[0]??o.initialPageParam:pp(o,s);if(l>0&&w==null)break;s=await h(s,w),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 Eh(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var $s,Po,hr,li,Oo,In,mp,fp=(mp=class extends el{constructor(t){super();J(this,Oo);J(this,$s);J(this,Po);J(this,hr);J(this,li);L(this,$s,t.client),this.mutationId=t.mutationId,L(this,hr,t.mutationCache),L(this,Po,[]),this.state=t.state||Mh(),this.setOptions(t.options),this.scheduleGc();}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime);}get meta(){return this.options.meta}addObserver(t){p(this,Po).includes(t)||(p(this,Po).push(t),this.clearGcTimeout(),p(this,hr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){L(this,Po,p(this,Po).filter(r=>r!==t)),this.scheduleGc(),p(this,hr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){p(this,Po).length||(this.state.status==="pending"?this.scheduleGc():p(this,hr).remove(this));}continue(){return p(this,li)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Le(this,Oo,In).call(this,{type:"continue"});},o={client:p(this,$s),meta:this.options.meta,mutationKey:this.options.mutationKey};L(this,li,Xa({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(i,s)=>{Le(this,Oo,In).call(this,{type:"failed",failureCount:i,error:s});},onPause:()=>{Le(this,Oo,In).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>p(this,hr).canRun(this)}));let n=this.state.status==="pending",a=!p(this,li).canStart();try{if(n)r();else {Le(this,Oo,In).call(this,{type:"pending",variables:t,isPaused:a}),p(this,hr).config.onMutate&&await p(this,hr).config.onMutate(t,this,o);let s=await this.options.onMutate?.(t,o);s!==this.state.context&&Le(this,Oo,In).call(this,{type:"pending",context:s,variables:t,isPaused:a});}let i=await p(this,li).start();return await p(this,hr).config.onSuccess?.(i,t,this.state.context,this,o),await this.options.onSuccess?.(i,t,this.state.context,o),await p(this,hr).config.onSettled?.(i,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(i,null,t,this.state.context,o),Le(this,Oo,In).call(this,{type:"success",data:i}),i}catch(i){try{await p(this,hr).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 p(this,hr).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 Le(this,Oo,In).call(this,{type:"error",error:i}),i}finally{p(this,hr).runNext(this);}}},$s=new WeakMap,Po=new WeakMap,hr=new WeakMap,li=new WeakMap,Oo=new WeakSet,In=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),St.batch(()=>{p(this,Po).forEach(o=>{o.onMutationUpdate(t);}),p(this,hr).notify({mutation:this,type:"updated",action:t});});},mp);function Mh(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var Go,fo,qs,hp,gp=(hp=class extends _o{constructor(t={}){super();J(this,Go);J(this,fo);J(this,qs);this.config=t,L(this,Go,new Set),L(this,fo,new Map),L(this,qs,0);}build(t,r,o){let n=new fp({client:t,mutationCache:this,mutationId:++bs(this,qs)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){p(this,Go).add(t);let r=tl(t);if(typeof r=="string"){let o=p(this,fo).get(r);o?o.push(t):p(this,fo).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(p(this,Go).delete(t)){let r=tl(t);if(typeof r=="string"){let o=p(this,fo).get(r);if(o)if(o.length>1){let n=o.indexOf(t);n!==-1&&o.splice(n,1);}else o[0]===t&&p(this,fo).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=tl(t);if(typeof r=="string"){let n=p(this,fo).get(r)?.find(a=>a.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=tl(t);return typeof r=="string"?p(this,fo).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){St.batch(()=>{p(this,Go).forEach(t=>{this.notify({type:"removed",mutation:t});}),p(this,Go).clear(),p(this,fo).clear();});}getAll(){return Array.from(p(this,Go))}find(t){let r={exact:true,...t};return this.getAll().find(o=>Ka(r,o))}findAll(t={}){return this.getAll().filter(r=>Ka(t,r))}notify(t){St.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return St.batch(()=>Promise.all(t.map(r=>r.continue().catch(Kt))))}},Go=new WeakMap,fo=new WeakMap,qs=new WeakMap,hp);function tl(e){return e.options.scope?.id}var Do,yp,bp=(yp=class extends _o{constructor(t={}){super();J(this,Do);this.config=t,L(this,Do,new Map);}build(t,r,o){let n=r.queryKey,a=r.queryHash??Es(n,r),i=this.get(a);return i||(i=new sp({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){p(this,Do).has(t.queryHash)||(p(this,Do).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=p(this,Do).get(t.queryHash);r&&(t.destroy(),r===t&&p(this,Do).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){St.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return p(this,Do).get(t)}getAll(){return [...p(this,Do).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>Qa(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>Qa(t,o)):r}notify(t){St.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){St.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){St.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Do=new WeakMap,yp);var Mt,vn,Pn,Yi,Ji,On,Zi,Xi,Cp,Hc=(Cp=class{constructor(e={}){J(this,Mt);J(this,vn);J(this,Pn);J(this,Yi);J(this,Ji);J(this,On);J(this,Zi);J(this,Xi);L(this,Mt,e.queryCache||new bp),L(this,vn,e.mutationCache||new gp),L(this,Pn,e.defaultOptions||{}),L(this,Yi,new Map),L(this,Ji,new Map),L(this,On,0);}mount(){bs(this,On)._++,p(this,On)===1&&(L(this,Zi,Ui.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,Mt).onFocus());})),L(this,Xi,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,Mt).onOnline());})));}unmount(){var e,t;bs(this,On)._--,p(this,On)===0&&((e=p(this,Zi))==null||e.call(this),L(this,Zi,void 0),(t=p(this,Xi))==null||t.call(this),L(this,Xi,void 0));}isFetching(e){return p(this,Mt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return p(this,vn).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return p(this,Mt).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=p(this,Mt).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(mo(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return p(this,Mt).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=p(this,Mt).get(o.queryHash)?.state.data,i=Gu(t,a);if(i!==void 0)return p(this,Mt).build(this,o).setData(i,{...r,manual:true})}setQueriesData(e,t,r){return St.batch(()=>p(this,Mt).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return p(this,Mt).get(t.queryHash)?.state}removeQueries(e){let t=p(this,Mt);St.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=p(this,Mt);return St.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=St.batch(()=>p(this,Mt).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(Kt).catch(Kt)}invalidateQueries(e,t={}){return St.batch(()=>(p(this,Mt).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=St.batch(()=>p(this,Mt).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,r);return r.throwOnError||(a=a.catch(Kt)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(o).then(Kt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=p(this,Mt).build(this,t);return r.isStaleByTime(mo(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Kt).catch(Kt)}fetchInfiniteQuery(e){return e.behavior=Uc(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Kt).catch(Kt)}ensureInfiniteQueryData(e){return e.behavior=Uc(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?p(this,vn).resumePausedMutations():Promise.resolve()}getQueryCache(){return p(this,Mt)}getMutationCache(){return p(this,vn)}getDefaultOptions(){return p(this,Pn)}setDefaultOptions(e){L(this,Pn,e);}setQueryDefaults(e,t){p(this,Yi).set(Zn(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...p(this,Yi).values()],r={};return t.forEach(o=>{ei(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){p(this,Ji).set(Zn(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...p(this,Ji).values()],r={};return t.forEach(o=>{ei(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...p(this,Pn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Es(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===Xn&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...p(this,Pn).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){p(this,Mt).clear(),p(this,vn).clear();}},Mt=new WeakMap,vn=new WeakMap,Pn=new WeakMap,Yi=new WeakMap,Ji=new WeakMap,On=new WeakMap,Zi=new WeakMap,Xi=new WeakMap,Cp);var Nc=Dn.createContext(void 0),jc=e=>{let t=Dn.useContext(Nc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},$c=({client:e,children:t})=>(Dn.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(Nc.Provider,{value:e,children:t}));var wp=Dn.createContext(false),Sp=()=>Dn.useContext(wp);wp.Provider;function Uh(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var Hh=Dn.createContext(Uh()),kp=()=>Dn.useContext(Hh);var xp=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?Ja(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},_p=e=>{Dn.useEffect(()=>{e.clearReset();},[e]);},Rp=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||Ja(r,[e.error,o]));var Ip=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));}},vp=(e,t)=>e.isLoading&&e.isFetching&&!t,Pp=(e,t)=>e?.suspense&&t.isPending,qc=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function Op(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=Sp(),n=kp(),a=jc(),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",Ip(i),xp(i,n,s),_p(n);let l=!a.getQueryCache().get(i.queryHash),[m]=Dn.useState(()=>new t(a,i)),d=m.getOptimisticResult(i),g=!o&&e.subscribed!==false;if(Dn.useSyncExternalStore(Dn.useCallback(k=>{let h=g?m.subscribe(St.batchCalls(k)):Kt;return m.updateResult(),h},[m,g]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),Dn.useEffect(()=>{m.setOptions(i);},[i,m]),Pp(i,d))throw qc(i,m,n);if(Rp({result:d,errorResetBoundary:n,throwOnError:i.throwOnError,query:s,suspense:i.suspense}))throw d.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,d),i.experimental_prefetchInRender&&!vo.isServer()&&vp(d,o)&&(l?qc(i,m,n):s?.promise)?.catch(Kt).finally(()=>{m.updateResult();}),i.notifyOnChangeProps?d:m.trackResult(d)}function Yo(e,t){return Op(e,Mc)}var rs=new Map;function Dp({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 Vn({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:a="transparent",backgroundColor:i="transparent",style:s}){let{colors:l}=V(),[m,d]=useState(false),[g,k]=useState(false),[h,b]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let x=rs.get(e);return x?{uri:e,xml:x}:null}),w=e?.toLowerCase().endsWith(".svg"),c=w&&e&&h?.uri===e?h.xml:null;useEffect(()=>{d(false),k(false);},[e]),useEffect(()=>{if(!w||!e)return;if(rs.has(e)){b({uri:e,xml:rs.get(e)});return}let x=false;return fetch(e).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.text()}).then(_=>{x||(rs.set(e,_),b({uri:e,xml:_}));}).catch(()=>{x||d(true);}),()=>{x=true;}},[e,w]);let S=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:S},s]});let y={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:a,backgroundColor:i,overflow:"hidden",alignItems:"center",justifyContent:"center",...s},u=t-n*2,f=r-n*2;return m?jsx(View,{style:[y,{backgroundColor:i||S}]}):w?jsxs(View,{style:y,children:[!!!c&&jsx(Dp,{width:u,height:f,borderRadius:o,color:S}),c?jsx(SvgXml,{xml:c,width:u,height:f,onError:()=>d(true)}):jsx(SvgUri,{uri:e,width:u,height:f,onError:()=>d(true)})]}):jsxs(View,{style:y,children:[!g&&jsx(Dp,{width:u,height:f,borderRadius:o,color:S}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:u,height:f},resizeMode:"contain",onLoad:()=>k(true),onError:()=>d(true)})]})}function Gc(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(rs.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{rs.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function kr({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:a,badge:i,showBalance:s=false,balanceAddress:l,balanceChainType:m,balanceChainId:d,balanceTokenAddress:g,publishableKey:k,projectName:h,leftIcon:b,onLeftAction:w}){let{colors:c,fonts:S,components:y}=V(),[u,f]=useState(null),[x,_]=useState(false),T=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!x)return;let R=Animated.loop(Animated.sequence([Animated.timing(T,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(T,{toValue:0,duration:700,useNativeDriver:true})]));return R.start(),()=>R.stop()},[x,T]),useEffect(()=>{if(!s||!l||!m||!d||!g||!k){f(null),_(false);return}let R=false;return _(true),xa(l,m,d,g,k).then(B=>{if(R)return;let E=B.balance,D=null;E&&(E.amount_usd!=null&&E.amount_usd!==""?D=`$${E.amount_usd}`:D="$0.00"),f(D);}).catch(()=>{R||f(null);}).finally(()=>{R||_(false);}),()=>{R=true;}},[s,l,m,d,g,k]);let C=T.interpolate({inputRange:[0,1],outputRange:[.4,1]});return jsxs(View,{style:gr.header,children:[jsx(View,{style:gr.leftContainer,children:r&&n?jsx(TouchableOpacity,{onPress:n,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(ws,{size:20,color:y.header.buttonColor,strokeWidth:2})}):b&&w?jsx(TouchableOpacity,{onPress:w,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:b}):jsx(View,{style:gr.spacer})}),jsxs(View,{style:gr.titleContainer,children:[jsxs(View,{style:gr.titleRow,children:[jsx(Text,{style:[gr.title,{color:y.header.titleColor,fontFamily:S.medium}],children:e}),i&&i.count>0&&jsx(View,{style:[gr.titleBadge,{backgroundColor:c.card}],children:jsx(Text,{style:[gr.titleBadgeText,{color:c.foregroundMuted,fontFamily:S.regular}],children:i.count})})]}),t?jsx(Text,{style:[gr.balanceText,{color:c.foregroundMuted,fontFamily:S.regular}],children:t}):null,s&&(x?jsx(Animated.View,{style:[gr.balanceSkeleton,{backgroundColor:c.cardHover,opacity:C}]}):u!=null?jsxs(Text,{style:[gr.balanceText,{color:c.foregroundMuted,fontFamily:S.regular}],children:[h?`${h} `:"","Balance: ",u]}):null)]}),jsx(View,{style:gr.rightContainer,children:o?jsx(TouchableOpacity,{onPress:a,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:y.header.buttonColor,strokeWidth:2})}):jsx(View,{style:gr.spacer})})]})}var gr=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 Gt({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:a}){let{components:i}=V(),s=a??i.card,l=s.backShadowColor!=="transparent",m={backgroundColor:s.backgroundColor,borderRadius:s.borderRadius,borderWidth:s.borderWidth,borderColor:s.borderColor},d=[Bp.wrapper,t,l&&{marginBottom:s.backShadowSpacing}],g=[m,r];return jsxs(View,{style:d,children:[l&&jsx(View,{style:[Bp.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:g,children:e}):jsx(View,{style:g,children:e})]})}var Bp=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function Ks({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:a}=V(),i=a.depositMenu.card,s=o?[...o].sort((l,m)=>l.position-m.position):[];return jsxs(Gt,{cardTokens:i,onPress:e,style:Fo.wrapper,contentStyle:Fo.container,children:[jsxs(View,{style:Fo.leftContent,children:[jsx(View,{style:[Fo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(Kl,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Fo.textContainer,children:[jsx(Text,{style:[Fo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Fo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Fo.rightContent,children:jsx(View,{style:Fo.networkIcons,children:s.map((l,m)=>{let d=l.icon_urls.find(g=>g.format==="png")?.url||l.icon_urls.find(g=>g.format==="svg")?.url;return jsx(View,{style:[Fo.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:s.length-m}],children:jsx(Vn,{uri:Z(d),width:20,height:20})},l.name)})})})]})}var Fo=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 Ys({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:a}=V(),i=a.depositMenu.card;return jsxs(Gt,{cardTokens:i,onPress:e,style:Jo.wrapper,contentStyle:Jo.container,children:[jsxs(View,{style:Jo.leftContent,children:[jsx(View,{style:[Jo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(_i,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Jo.textContainer,children:[jsx(Text,{style:[Jo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Jo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Jo.rightContent,children:jsx(View,{style:Jo.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(Vn,{uri:Z(l),width:32,height:20,borderRadius:4},s.name)})})})]})}var Jo=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 Js({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:a}=V(),i=a.depositMenu.card;return jsx(Gt,{cardTokens:i,onPress:e,style:Zo.wrapper,contentStyle:Zo.container,children:jsxs(View,{style:Zo.leftContent,children:[jsxs(View,{style:[Zo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:[jsx(bo,{size:20,color:i.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[Zo.badge,{backgroundColor:i.iconColor,borderRadius:a.badge.borderRadius}],children:jsx(Text,{style:[Zo.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:Zo.textContainer,children:[jsx(Text,{style:[Zo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Zo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var Zo=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 Xs({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=V(),a=n.depositMenu.card;return jsxs(Gt,{cardTokens:a,onPress:e,style:Vo.wrapper,contentStyle:Vo.container,children:[jsxs(View,{style:Vo.leftContent,children:[jsx(View,{style:[Vo.iconContainer,{borderRadius:a.iconContainerBorderRadius}],children:jsx(ga,{size:20,color:a.iconColor,strokeWidth:2})}),jsxs(View,{style:Vo.textContainer,children:[jsx(Text,{style:[Vo.title,{color:a.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[Vo.subtitle,{color:a.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:Vo.rightContent,children:jsx(View,{style:Vo.badge,children:jsx(Text,{style:[Vo.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}var Vo=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 Mp=1e4,zp=2500,Up=3e3,Hp=6e4;function ea(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:a,modalOpenedAt:i,depositWalletId:s,depositExecutions:l,trackedExecutions:m,setDepositExecutions:d,setTrackedExecutions:g,setLatestExecution:k,setShowStatusSheet:h,onDepositSuccess:b,onExecutionsChange:w,onDepositError:c}=e,[S,y]=useState(false),[u,f]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;y(false),t==="auto_ui"&&f(false);let _=setTimeout(()=>{y(true),t==="auto_ui"&&f(true);},Mp);return ()=>clearTimeout(_)},[t,r,o]),useEffect(()=>{if(!n||!i)return;let _=new Date(i.getTime()-Hp),T=setInterval(async()=>{try{let B=[...(await No(n,a)).data??[]].sort((D,P)=>{let q=D.created_at?new Date(D.created_at).getTime():0;return (P.created_at?new Date(P.created_at).getTime():0)-q}),E=null;for(let D of B){let P=D.created_at?new Date(D.created_at):null;if(!P||P<=_)continue;let q=m.get(D.id);if(!q){E=D;break}if(["pending","waiting","delayed"].includes(q)&&D.status==="succeeded"){E=D;break}}if(E){let D=E;d(P=>{let q=P.findIndex(j=>j.id===D.id);if(q>=0){let j=[...P];return j[q]=D,j}return [...P,D]}),g(P=>{let q=new Map(P);return q.set(D.id,D.status),q}),k(D),h(!0),D.status==="succeeded"&&b?.({message:"Deposit completed successfully",executionId:D.id}),w?.([...l,D]);}}catch(C){c?.({message:"Failed to check deposit status",error:C});}},zp);return ()=>clearInterval(T)},[n,a,i,m,l,w,b,c]),useEffect(()=>{if(!S||!s)return;let _=async()=>{try{await wa(s,a);}catch{}};_();let T=setInterval(_,Up);return ()=>clearInterval(T)},[S,s,a]),{pollingEnabled:S,showWaitingUi:u,handleIveDeposited:()=>{y(true),f(true);}}}function ss({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:a,isDark:i}=V(),s=i?"#1a1a1a":"#ffffff",l=i?"#ffffff":"#000000",m=n||s;return jsxs(View,{style:[jp.container,{width:t,height:t}],children:[jsx(tg,{value:e||"placeholder",size:t,backgroundColor:s,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[jp.logoContainer,{width:o+12,height:o+12,backgroundColor:m,borderRadius:(o+12)/2}],children:jsx(Vn,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var jp=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function Qp(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function ig(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 as({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:a,amountUsd:i,onClose:s,borderTopLeftRadius:l,borderTopRightRadius:m}){let{colors:d,fonts:g,components:k}=V(),[h,b]=useState(false),w=t==="pending"||t==="waiting"||t==="delayed",c=t==="succeeded",S=()=>{o&&Linking.openURL(o);},y=()=>{n&&Linking.openURL(n);};return jsx(ct,{visible:e,onClose:s,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:m,children:jsxs(View,{style:Ot.container,children:[jsx(TouchableOpacity,{style:Ot.closeButton,onPress:s,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:k.header.buttonColor,strokeWidth:2})}),jsx(View,{style:Ot.iconContainer,children:w?jsx(ht,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:Z(r)},style:Ot.tokenIconFill}):jsx(View,{style:[Ot.tokenIconFill,{backgroundColor:d.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:Z(r)},style:Ot.tokenIconLarge}):jsx(View,{style:[Ot.tokenIconLarge,{backgroundColor:d.cardHover}]}),jsx(View,{style:[Ot.statusBadge,{backgroundColor:k.container.iconBackgroundColor}],children:jsx(qe,{size:16,color:k.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[Ot.title,{color:k.container.titleColor,fontFamily:g.semibold}],children:w?"Deposit Processing":"Deposit Complete"}),i!==void 0&&jsxs(Text,{style:[Ot.amount,{color:k.container.titleColor,fontFamily:g.bold}],children:["$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),a&&jsx(Text,{style:[Ot.date,{color:k.container.subtitleColor,fontFamily:g.regular}],children:ig(a)}),jsx(Text,{style:[Ot.subtitle,{color:k.container.subtitleColor,fontFamily:g.regular}],children:w?"This usually takes less than a minute.":"Your account has been credited successfully!"}),c&&(o||n)&&jsxs(View,{style:Ot.detailsSection,children:[jsx(View,{style:[Ot.divider,{backgroundColor:d.border}]}),jsxs(TouchableOpacity,{style:Ot.detailsToggle,onPress:()=>b(!h),children:[jsx(Text,{style:[Ot.detailsToggleText,{color:k.container.actionTitle,fontFamily:g.medium}],children:h?"See less":"See more details"}),h?jsx(wo,{size:18,color:k.container.actionColor,strokeWidth:2}):jsx(Pt,{size:18,color:k.container.actionColor,strokeWidth:2})]}),h&&jsxs(View,{style:Ot.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[Ot.txButton,{backgroundColor:k.card.backgroundColor,borderColor:d.border}],onPress:S,children:[jsx(Text,{style:[Ot.txLabel,{color:k.card.titleColor,fontFamily:g.medium}],children:"Deposit tx"}),jsx(Text,{style:[Ot.txHash,{color:k.card.subtitleColor,fontFamily:g.regular}],children:Qp(o)}),jsx(Co,{size:16,color:k.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[Ot.txButton,{backgroundColor:k.card.backgroundColor,borderColor:d.border}],onPress:y,children:[jsx(Text,{style:[Ot.txLabel,{color:k.card.titleColor,fontFamily:g.medium}],children:"Completion tx"}),jsx(Text,{style:[Ot.txHash,{color:k.card.subtitleColor,fontFamily:g.regular}],children:Qp(n)}),jsx(Co,{size:16,color:k.card.actionColor,strokeWidth:2})]})]})]})]})})}var Ot=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 ll({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:a,fonts:i,components:s}=V();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[ui.iveDepositedButton,{backgroundColor:a.primary,borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor}],children:jsx(Text,{style:[ui.iveDepositedButtonText,{color:a.primaryForeground??"#FFF",fontFamily:i.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[ui.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:[ui.detailIcon,{backgroundColor:s.card.iconBackgroundColor,borderRadius:s.card.iconContainerBorderRadius}],children:jsx(Gl,{size:14,color:s.card.iconColor,strokeWidth:2})}),jsxs(View,{style:ui.processingCardText,children:[jsx(Text,{style:[ui.processingCardTitle,{color:s.card.titleColor,fontFamily:i.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[ui.processingCardSubtitle,{color:s.card.subtitleColor,fontFamily:i.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var ui=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 ta=(e,t)=>`${t}:${e}`,fg=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function dl({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:d="auto_ui",onExecutionsChange:g,onDepositSuccess:k,onDepositError:h,borderTopLeftRadius:b,borderTopRightRadius:w,sheetBorderRadius:c}){let{colors:S,fonts:y,components:u}=V(),f=s&&l?`${s}:${l}`:"solana:mainnet",[x,_]=useState("USDC"),[T,C]=useState(f),[R,B]=useState([]),[E,D]=useState(true),[P,q]=useState([]),[j,fe]=useState(true),[Ke,De]=useState(false),[G,Se]=useState(false),[he,Ie]=useState(false),[Ge,ke]=useState(false),[Y,Te]=useState([]),[st,We]=useState(new Map),[Ye]=useState(()=>new Date),[Ae,Ee]=useState(null),[Me,pe]=useState(false),[ee,be]=useState(null),[pt,M]=useState(false),W=new Map;P.forEach(N=>{N.chains.forEach(re=>{let _e=`${re.chain_type}:${re.chain_id}`;W.has(_e)||W.set(_e,re);});});let se=Array.from(W.values()),oe=fg(T),xt=se.find(N=>N.chain_type===oe.chainType&&N.chain_id===oe.chainId)?.chain_type||"ethereum",ce=Ho(R,xt),ae=ce?.address||"",ze=useRef(false);useEffect(()=>{async function N(){try{fe(!0),Ee(null);let _e=await Nn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(q(_e.data),_e.data.length>0&&!ze.current){ze.current=!0;let ue,ne;if(s&&l)if(m)for(let O of _e.data){let ft=O.chains.find(Fe=>Fe.chain_type===s&&Fe.chain_id===l&&Fe.token_address.toLowerCase()===m.toLowerCase());if(ft){ue=O,ne=ft;break}}else for(let O of _e.data){let ft=O.chains.find(Fe=>Fe.chain_type===s&&Fe.chain_id===l);if(ft){ue=O,ne=ft;break}}if(!ue&&a)for(let O of _e.data){let ft=O.chains.find(Fe=>Fe.token_address.toLowerCase()===a.toLowerCase());if(ft){ue=O,ne=ft;break}}ue||(ue=_e.data.find(O=>O.symbol==="USDC"),ue&&ue.chains.length>0&&(ne=ue.chains[0])),ue||(ue=_e.data.find(O=>O.symbol==="USDT"),ue&&ue.chains.length>0&&(ne=ue.chains[0])),ue||(ue=_e.data[0],ue.chains.length>0&&(ne=ue.chains[0])),ue&&_(ue.symbol),ne&&C(ta(ne.chain_id,ne.chain_type));}}catch(re){console.error("Error fetching supported tokens:",re),Ee("Failed to load supported tokens"),h?.({message:"Failed to load supported tokens",error:re});}finally{fe(false);}}N();},[t,h,s,l,m,a,n,o]),useEffect(()=>{async function N(){try{D(!0),Ee(null);let re=await Uo({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);B(re.data);}catch(re){console.error("Error fetching wallets:",re),Ee("Failed to load wallets"),h?.({message:"Failed to load wallets",error:re});}finally{D(false);}}N();},[e,r,o,n,a,t,h]);let Yt=ce?.id??"",{showWaitingUi:mt,handleIveDeposited:de}=ea({depositConfirmationMode:d,depositAddress:ae,chain:T,externalUserId:e,publishableKey:t,modalOpenedAt:Ye,depositWalletId:Yt,depositExecutions:Y,trackedExecutions:st,setDepositExecutions:Te,setTrackedExecutions:We,setLatestExecution:be,setShowStatusSheet:pe,onDepositSuccess:k,onExecutionsChange:g,onDepositError:h});useEffect(()=>{if(!P.length)return;let N=P.find(_e=>_e.symbol===x);if(!N||N.chains.length===0)return;if(!N.chains.some(_e=>ta(_e.chain_id,_e.chain_type)===T)){let _e=N.chains[0];C(ta(_e.chain_id,_e.chain_type));}},[x,P,T]);let et=P.find(N=>N.symbol===x),xr=et?.chains||[],_t=xr.find(N=>ta(N.chain_id,N.chain_type)===T),io=async()=>{if(ae)try{Clipboard.setString(ae),De(!0),setTimeout(()=>De(!1),2e3);}catch(N){console.error("Failed to copy:",N);}},Or=_t?.estimated_price_impact_percent??0,ir=_t?.max_slippage_percent??.25,$t=_t?.minimum_deposit_amount_usd??3;if(j)return jsxs(View,{style:F.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:S.primary}),jsx(Text,{style:[F.loadingText,{color:S.foregroundMuted,fontFamily:y.regular}],children:"Loading currencies..."})]});if(Ae&&P.length===0)return jsxs(View,{style:F.errorContainer,children:[jsx(Text,{style:[F.errorText,{color:S.error,fontFamily:y.regular}],children:Ae}),jsx(Text,{style:[F.errorHint,{color:S.foregroundMuted,fontFamily:y.regular}],children:"Please check your network connection and try again."})]});let xe=()=>jsxs(ct,{visible:he,onClose:()=>Ie(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c?.tokenSelector?.borderTopLeftRadius??b,borderTopRightRadius:c?.tokenSelector?.borderTopRightRadius??w,children:[jsxs(View,{style:[F.sheetHeader,{borderBottomColor:S.border}],children:[jsx(View,{style:F.sheetHeaderSpacer}),jsx(Text,{style:[F.sheetTitle,{color:u.header.titleColor,fontFamily:y.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>Ie(false),style:F.sheetCloseButton,children:jsx(tt,{size:20,color:u.header.buttonColor,strokeWidth:2})})]}),jsx(BottomSheetScrollView,{style:F.sheetList,contentContainerStyle:F.sheetListContent,showsVerticalScrollIndicator:false,children:P.map(N=>jsxs(TouchableOpacity$1,{onPress:()=>{_(N.symbol),Ie(false);},activeOpacity:.7,style:[F.sheetItem,{backgroundColor:x===N.symbol?u.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:Z(ge(N,"png"))},style:F.sheetItemIcon}),jsxs(View,{style:F.sheetItemText,children:[jsx(Text,{style:[F.sheetItemTitle,{color:u.card.titleColor,fontFamily:y.medium}],children:N.symbol}),jsxs(Text,{style:[F.sheetItemSubtitle,{color:u.card.subtitleColor,fontFamily:y.regular}],children:[N.chains.length," network",N.chains.length!==1?"s":""," available"]})]}),x===N.symbol&&jsx(qe,{size:20,color:S.primary,strokeWidth:2})]},N.symbol))})]}),at=()=>jsxs(ct,{visible:Ge,onClose:()=>ke(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c?.chainSelector?.borderTopLeftRadius??b,borderTopRightRadius:c?.chainSelector?.borderTopRightRadius??w,children:[jsxs(View,{style:[F.sheetHeader,{borderBottomColor:S.border}],children:[jsx(View,{style:F.sheetHeaderSpacer}),jsx(Text,{style:[F.sheetTitle,{color:u.header.titleColor,fontFamily:y.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>ke(false),style:F.sheetCloseButton,children:jsx(tt,{size:20,color:u.header.buttonColor,strokeWidth:2})})]}),jsx(BottomSheetScrollView,{style:F.sheetList,contentContainerStyle:F.sheetListContent,showsVerticalScrollIndicator:false,children:xr.map(N=>{let re=ta(N.chain_id,N.chain_type),_e=T===re;return jsxs(TouchableOpacity$1,{onPress:()=>{C(re),ke(false);},activeOpacity:.7,style:[F.sheetItem,{backgroundColor:_e?u.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:Z(ge(N,"png"))},style:F.sheetItemIcon}),jsxs(View,{style:F.sheetItemText,children:[jsx(Text,{style:[F.sheetItemTitle,{color:u.card.titleColor,fontFamily:y.medium}],children:N.chain_name}),jsxs(Text,{style:[F.sheetItemSubtitle,{color:u.card.subtitleColor,fontFamily:y.regular}],children:["Min deposit: $",N.minimum_deposit_amount_usd]})]}),_e&&jsx(qe,{size:20,color:S.primary,strokeWidth:2})]},re)})})]});return jsxs(View,{style:F.container,children:[jsxs(View,{style:F.selectorSection,children:[jsx(Text,{style:[F.selectorLabel,{color:u.card.labelColor,fontFamily:y.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>Ie(true),style:[F.selector,{backgroundColor:u.card.backgroundColor,borderRadius:u.card.borderRadius,borderWidth:u.card.borderWidth,borderColor:u.card.borderColor}],children:[et&&jsx(Image,{source:{uri:Z(ge(et,"png"))},style:F.selectorIcon}),jsx(Text,{style:[F.selectorText,{color:u.card.titleColor,fontFamily:y.medium}],children:x}),jsx(Pt,{size:16,color:u.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:F.selectorSection,children:[jsxs(Text,{style:[F.selectorLabel,{color:u.card.labelColor,fontFamily:y.regular}],children:["Network"," ",jsxs(Text,{style:[F.minDeposit,{fontFamily:y.regular}],children:["($",$t," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>ke(true),style:[F.selector,{backgroundColor:u.card.backgroundColor,borderRadius:u.card.borderRadius,borderWidth:u.card.borderWidth,borderColor:u.card.borderColor}],children:[_t&&jsx(Image,{source:{uri:Z(ge(_t,"png"))},style:F.selectorIcon}),jsx(Text,{style:[F.selectorText,{color:u.card.titleColor,fontFamily:y.medium}],numberOfLines:1,children:_t?.chain_name||"Select network"}),jsx(Pt,{size:16,color:u.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:F.qrContainer,children:jsx(View,{style:[F.qrWrapper,{backgroundColor:S.background,borderRadius:u.card.borderRadius,borderWidth:u.card.borderWidth>0?u.card.borderWidth:1,borderColor:u.card.borderColor}],children:E?jsxs(View,{style:F.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:S.primary}),jsx(Text,{style:[F.loadingText,{color:S.foregroundMuted,fontFamily:y.regular}],children:"Loading..."})]}):ae?jsx(ss,{value:ae,size:160,logoUri:Z(ge(_t,"png")||Ht("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:F.qrLoading,children:jsx(Text,{style:[F.errorText,{color:S.error,fontFamily:y.regular}],children:"No address available"})})})}),jsxs(View,{style:F.addressSection,children:[jsxs(View,{style:F.addressHeader,children:[jsx(Text,{style:[F.addressLabel,{color:u.card.labelColor,fontFamily:y.medium}],children:"Deposit Address"}),Ke&&jsxs(View,{style:F.copiedIndicator,children:[jsx(qe,{size:14,color:S.success,strokeWidth:2}),jsx(Text,{style:[F.copiedText,{color:S.success,fontFamily:y.regular}],children:"Copied"})]})]}),jsxs(Gt,{cardTokens:u.transferCrypto.depositAddress.card,onPress:!E&&ae?io:void 0,contentStyle:F.addressBox,children:[jsx(Text,{style:[F.addressText,{color:u.card.titleColor,fontFamily:y.regular}],numberOfLines:2,children:E?"Loading...":ae||"No address available"}),jsx(View,{style:F.addressCopyIcon,children:jsx(Hn,{size:16,color:u.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[F.detailsCard,{backgroundColor:u.card.backgroundColor,borderRadius:u.card.borderRadius,borderWidth:u.card.borderWidth,borderColor:u.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Se(!G),style:F.detailsHeader,children:[jsxs(View,{style:F.detailsRow,children:[jsx(View,{style:[F.detailIcon,{backgroundColor:u.card.iconBackgroundColor,borderRadius:u.card.iconContainerBorderRadius}],children:jsx(bo,{size:12,color:u.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[F.detailsLabel,{color:u.card.titleColor,fontFamily:y.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:F.chevronContainer,children:G?jsx(wo,{size:16,color:u.card.actionColor,strokeWidth:2}):jsx(Pt,{size:16,color:u.card.actionColor,strokeWidth:2})})]}),G&&jsxs(View,{style:F.detailsContent,children:[jsxs(View,{style:F.detailsRow,children:[jsx(View,{style:[F.detailIcon,{backgroundColor:u.card.iconBackgroundColor,borderRadius:u.card.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:u.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[F.detailsLabel,{color:u.card.titleColor,fontFamily:y.regular}],children:["Price impact: ",Or.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>M(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ii,{size:14,color:u.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:F.detailsRow,children:[jsx(View,{style:[F.detailIcon,{backgroundColor:u.card.iconBackgroundColor,borderRadius:u.card.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:u.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[F.detailsLabel,{color:u.card.titleColor,fontFamily:y.regular}],children:["Slippage: Auto \u2022 ",ir.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>M(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ii,{size:14,color:u.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:F.detailsRow,children:[jsx(View,{style:[F.detailIcon,{backgroundColor:u.card.iconBackgroundColor,borderRadius:u.card.iconContainerBorderRadius}],children:jsx(fa,{size:12,color:u.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[F.detailsLabel,{color:u.card.titleColor,fontFamily:y.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(ll,{depositConfirmationMode:d,depositAddress:ae,showWaitingUi:mt,latestExecution:ee,onIveDeposited:de}),jsx(TouchableOpacity$1,{style:F.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[F.termsText,{color:S.primary,fontFamily:y.regular}],children:"Terms apply"})}),xe(),at(),jsxs(ct,{visible:pt,onClose:()=>M(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:c?.infoSheet?.borderTopLeftRadius??b,borderTopRightRadius:c?.infoSheet?.borderTopRightRadius??w,children:[jsxs(View,{style:[F.sheetHeader,{borderBottomColor:S.border}],children:[jsx(View,{style:F.sheetHeaderSpacer}),jsx(Text,{style:[F.sheetTitle,{color:u.header.titleColor,fontFamily:y.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>M(false),style:F.sheetCloseButton,children:jsx(tt,{size:20,color:u.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:F.infoSheetContent,children:[jsxs(View,{style:[F.infoCard,{backgroundColor:u.card.backgroundColor,borderRadius:u.card.borderRadius,borderWidth:u.card.borderWidth,borderColor:u.card.borderColor}],children:[jsxs(View,{style:F.infoCardHeader,children:[jsx(View,{style:[F.infoCardIcon,{backgroundColor:u.card.iconBackgroundColor,borderRadius:u.card.iconContainerBorderRadius}],children:jsx(mn,{size:16,color:u.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[F.infoCardTitle,{color:u.card.titleColor,fontFamily:y.medium}],children:"Price Impact"}),jsxs(Text,{style:[F.infoCardValue,{color:u.card.titleColor,fontFamily:y.medium}],children:[Or.toFixed(2),"%"]})]}),jsx(Text,{style:[F.infoCardDescription,{color:u.card.descriptionColor,fontFamily:y.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:[F.infoCard,{backgroundColor:u.card.backgroundColor,borderRadius:u.card.borderRadius,borderWidth:u.card.borderWidth,borderColor:u.card.borderColor}],children:[jsxs(View,{style:F.infoCardHeader,children:[jsx(View,{style:[F.infoCardIcon,{backgroundColor:u.card.iconBackgroundColor,borderRadius:u.card.iconContainerBorderRadius}],children:jsx(fn,{size:16,color:u.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[F.infoCardTitle,{color:u.card.titleColor,fontFamily:y.medium}],children:"Max Slippage"}),jsxs(Text,{style:[F.infoCardValue,{color:u.card.titleColor,fontFamily:y.medium}],children:[ir.toFixed(2),"%"]})]}),jsx(Text,{style:[F.infoCardDescription,{color:u.card.descriptionColor,fontFamily:y.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."})]})]})]}),ee&&jsx(as,{visible:Me,status:ee.status,tokenIconUrl:ee.destination_token_metadata?.icon_urls?.find(N=>N.format==="png")?.url||ee.destination_token_metadata?.icon_url||ge(et,"png"),explorerUrl:ee.explorer_url,completionExplorerUrl:ee.destination_explorer_url,date:ee.created_at?new Date(ee.created_at):void 0,amountUsd:ee.source_amount_usd?parseFloat(ee.source_amount_usd):void 0,onClose:()=>pe(false),borderTopLeftRadius:c?.depositStatus?.borderTopLeftRadius??b,borderTopRightRadius:c?.depositStatus?.borderTopRightRadius??w})]})}var F=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 ul({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:a}=V();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[pi.container,{backgroundColor:a.card.backgroundColor,borderRadius:a.list.rowBorderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:pi.leftContent,children:[jsx(View,{style:[pi.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:Z(ge(e,"png"))},style:pi.icon})}),jsxs(View,{style:pi.textContainer,children:[jsx(Text,{style:[pi.name,{color:a.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[pi.code,{color:a.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(qe,{size:16,color:o.primary,strokeWidth:2})]})}var pi=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 oa({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:a}=V();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:Jp.headerContainer,children:jsx(Text,{style:[Jp.title,{color:a.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(i=>jsx(ul,{currency:i,isSelected:r.toLowerCase()===i.currency_code.toLowerCase(),onSelect:o},i.currency_code))]})}var Jp=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function ml({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:d}=V(),[g,k]=useState(""),h=o.map(f=>r.find(x=>x.currency_code.toLowerCase()===f.toLowerCase())).filter(f=>f!==void 0),b=r.filter(f=>!o.includes(f.currency_code.toLowerCase())),w=f=>{if(!g)return f;let x=g.toLowerCase();return f.filter(_=>_.name.toLowerCase().includes(x)||_.currency_code.toLowerCase().includes(x))},c=w(h),S=w(b),y=f=>{a(f),t(false),k("");},u=()=>{t(false),k("");};return jsxs(ct,{visible:e,onClose:u,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsx(kr,{title:"Currency",showBack:false,onClose:u}),jsx(View,{style:mi.searchContainer,children:jsx(TextInput,{style:[mi.searchInput,{backgroundColor:d.search.backgroundColor,color:d.search.inputColor,fontFamily:m.regular,borderRadius:d.input.borderRadius,borderWidth:d.input.borderWidth,borderColor:d.input.borderColor}],value:g,onChangeText:k,placeholder:"Search",placeholderTextColor:d.search.placeholderColor})}),jsx(BottomSheetScrollView,{style:mi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:mi.listContent,children:[jsx(oa,{title:"Popular currencies",currencies:c,selectedCurrency:n,onSelect:y}),c.length>0&&S.length>0&&jsx(View,{style:mi.sectionSpacer}),jsx(oa,{title:"All currencies",currencies:S,selectedCurrency:n,onSelect:y}),c.length===0&&S.length===0&&jsx(View,{style:mi.noResultsContainer,children:jsx(Text,{style:[mi.noResultsText,{color:d.container.subtitleColor,fontFamily:m.regular}],children:"No currencies found"})})]})})]})}var mi=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 gd(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 gl({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:a,destinationChainType:i,destinationChainId:s,destinationTokenAddress:l,onDepositSuccess:m,onDepositError:d,borderTopLeftRadius:g,borderTopRightRadius:k,sheetBorderRadius:h}){let{colors:b,fonts:w,components:c}=V(),[S,y]=useState(""),[u,f]=useState("usd"),[x,_]=useState(false),[T,C]=useState(false),[R,B]=useState([]),[E,D]=useState(false),[P,q]=useState(null),[j,fe]=useState(null),[Ke,De]=useState("amount"),[G,Se]=useState(null),[he,Ie]=useState(true),[Ge,ke]=useState(null),[Y,Te]=useState(false),st=useRef(null),We=useRef(false);useEffect(()=>{st.current=G;},[G]),useEffect(()=>{We.current=Y;},[Y]);let[Ye,Ae]=useState([]),[Ee,Me]=useState(true),[pe,ee]=useState(60),[be,pt]=useState([]),[M,W]=useState([]),[se,oe]=useState(null),[ve,xt]=useState(null),[ce,ae]=useState(true),[ze,Yt]=useState(null),[mt,de]=useState(false),[et,xr]=useState(null),[_t,io]=useState(false),[Or,ir]=useState(false),[$t,xe]=useState(false),[at,N]=useState(null),re=r??Ke,_e=useRef(null),ue=be.find($=>$.currency_code.toLowerCase()===u.toLowerCase()),ne=useCallback($=>{De($),$==="quotes"?o?.($,R.length):o?.($);},[R.length,o]);useEffect(()=>{async function $(){try{let ie=await Is();xt(ie);}catch(ie){console.error("Error fetching user IP:",ie);}finally{ae(false);}}$();},[]),useEffect(()=>{async function $(){try{let ie=await Uo({external_user_id:e,recipient_address:a,destination_chain_type:i,destination_chain_id:s,destination_token_address:l},t);Ae(ie.data);}catch(ie){console.error("Error fetching wallets:",ie),q("Failed to load wallet addresses");}finally{Me(false);}}$();},[e,a,i,s,l,t]);let O=n||se?.symbol.toUpperCase()||"USDC",ft=Di(se?.icon_urls,"png")||se?.icon_url,Fe=Di(se?.chain_icon_urls,"png")||se?.chain_icon_url;useEffect(()=>{async function $(){try{let ie=await tc(t);pt(ie.data),W(ie.preferred||[]);}catch(ie){console.error("Error fetching fiat currencies:",ie);}}$();},[t]),useEffect(()=>{if(x||be.length===0||!ve?.alpha2)return;let $=ve.alpha2.toUpperCase(),ie=be.find(wt=>wt.country_codes.includes($));if(ie)f(ie.currency_code.toLowerCase()),!S&&!T&&y(String(ie.default_amount??100));else if(!S&&!T){let wt=be.find(Dr=>Dr.currency_code.toLowerCase()==="usd");wt&&y(String(wt.default_amount??100));}},[be,ve,x,S,T]),useEffect(()=>{if(be.length!==0){if(_e.current!==null&&_e.current!==u){let $=be.find(ie=>ie.currency_code.toLowerCase()===u.toLowerCase());$&&y(String($.default_amount??100));}_e.current=u;}},[u,be]),useEffect(()=>{async function $(){try{let ie=await Jl({chain_type:i||"",chain_id:s||"",token_address:l||""},t);oe(ie);}catch(ie){console.error("Error fetching supported tokens:",ie);}}$();},[i,s,l,t]),useEffect(()=>{async function $(){if(!(!l||!s||!i)&&!ce){de(true);try{let ie=await ec({country_code:ve?.alpha2?.toUpperCase()||"US",subdivision_code:ve?.state||void 0,token_address:l,chain_id:s,chain_type:i},t);Yt(ie);}catch(ie){console.error("Error fetching default onramp token:",ie);}finally{de(false);}}}$();},[l,s,i,ve,ce,t]),useEffect(()=>{let $=parseFloat(S);if(isNaN($)||$<=0){B([]),fe(null);return}if(!ze||mt){B([]),Se(null);return}let ie=be.find(Dr=>Dr.currency_code.toLowerCase()===u.toLowerCase());if(ie){if($<ie.minimum_amount){B([]),Se(null),fe(`Minimum amount is ${gd(u)}${ie.minimum_amount.toLocaleString()}`);return}if($>ie.maximum_amount){B([]),Se(null),fe(`Maximum amount is ${gd(u)}${ie.maximum_amount.toLocaleString()}`);return}}fe(null);let wt=setTimeout(()=>{un($);},500);return ()=>clearTimeout(wt)},[S,u,t,ze,mt,be]);let un=async $=>{if(!ze){q("Loading token information...");return}D(true),q(null);try{let ie={country_code:ve?.alpha2?.toUpperCase()||"US",source_amount:$.toString(),source_currency:u.toLowerCase(),destination_currency:ze.destination_currency,destination_network:ze.destination_network,subdivision_code:ve?.state||void 0},wt=await Zl(ie,t);B(wt.data);let Dr=We.current,ys=st.current;if(Dr&&ys){let ao=wt.data.find(lo=>lo.service_provider===ys.service_provider);if(ao){if(Se(ao),wt.data.length>0){let lo=wt.data.reduce((Fr,zo)=>zo.destination_amount>Fr.destination_amount?zo:Fr);Ge||ke(lo.service_provider),Ie(ao.service_provider===Ge);}}else if(wt.data.length>0){let lo=wt.data.reduce((Fr,zo)=>zo.destination_amount>Fr.destination_amount?zo:Fr);Se(lo),ke(lo.service_provider),Ie(!0),Te(!1);}}else if(wt.data.length>0){let ao=wt.data.reduce((lo,Fr)=>Fr.destination_amount>lo.destination_amount?Fr:lo);Se(ao),ke(ao.service_provider),Ie(!0);}ee(60);}catch(ie){console.error("Failed to fetch quotes:",ie),q("Failed to fetch quotes. Please try again."),B([]);}finally{D(false);}};useEffect(()=>{if(R.length===0)return;let $=setInterval(()=>{ee(ie=>{if(ie<=1){let wt=parseFloat(S);return !isNaN(wt)&&wt>0&&un(wt),60}return ie-1});},1e3);return ()=>clearInterval($)},[R.length,S]);let Si=$=>{(/^\d*\.?\d{0,2}$/.test($)||$==="")&&(y($),C(true));},ki=$=>{y($.toString()),C(true);},yo=async()=>{if(G&&ze)try{let $=ze.destination_token_metadata.chain_type,ie=Ho(Ye,$);if(!ie?.address){q("Wallet address not available");return}let wt={service_provider:G.service_provider,country_code:G.country_code?.toUpperCase()||ve?.alpha2?.toUpperCase()||"US",source_currency:G.source_currency,source_amount:S,destination_currency:G.destination_currency,destination_network:G.destination_network,wallet_address:ie.address,subdivision_code:ve?.state||void 0},Dr=await Xl(wt,t);xr({provider:G,sourceCurrency:u,sourceAmount:S,sessionUrl:Dr.url}),N(Dr.url),xe(!0);}catch($){console.error("Failed to create session:",$),q("Failed to start payment flow"),d?.({message:"Failed to start payment flow",error:$});}},Ti=gd(u),so=()=>{xe(false),ne("onramp"),m?.({message:"Payment flow completed"});},Mo=()=>jsx(vg,{visible:$t,onClose:so,url:at,providerName:G?.service_provider_display_name||"Complete Payment",colors:b,fonts:w,borderTopLeftRadius:h?.webView?.borderTopLeftRadius??g,borderTopRightRadius:h?.webView?.borderTopRightRadius??k});return re==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:H.amountViewContainer,children:[jsxs(BottomSheetScrollView,{style:H.scrollContainer,contentContainerStyle:H.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:H.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>io(true),style:[H.currencyButton,{backgroundColor:c.card.backgroundColor,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],children:[ue&&jsx(Image,{source:{uri:Z(ge(ue,"png"))},style:H.currencyIcon}),jsx(Text,{style:[H.currencyText,{color:c.card.titleColor,fontFamily:w.medium}],children:u.toUpperCase()}),jsx(Pt,{size:16,color:c.card.actionColor,strokeWidth:2})]})}),jsx(ml,{open:_t,onOpenChange:io,currencies:be,preferredCurrencyCodes:M,selectedCurrency:u,onSelectCurrency:$=>{f($.toLowerCase()),_(true);},borderTopLeftRadius:h?.currencyModal?.borderTopLeftRadius??g,borderTopRightRadius:h?.currencyModal?.borderTopRightRadius??k}),jsx(View,{style:H.amountContainer,children:jsxs(View,{style:H.amountInputRow,children:[jsx(Text,{style:[H.currencySymbol,{color:c.container.titleColor,fontFamily:w.medium}],children:Ti}),jsx(TextInput,{style:[H.amountInput,{color:c.container.titleColor,fontFamily:w.medium}],value:S,onChangeText:Si,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:b.foregroundMuted})]})}),ue?.suggested_amounts&&ue.suggested_amounts.length>0&&jsx(View,{style:H.quickAmounts,children:ue.suggested_amounts.map($=>jsx(TouchableOpacity$1,{onPress:()=>ki($),style:[H.quickAmountButton,{backgroundColor:c.card.backgroundColor,borderRadius:c.button.borderRadius,borderWidth:parseFloat(S)===$?2:c.button.borderWidth,borderColor:parseFloat(S)===$?b.primary:c.button.borderColor}],children:jsxs(Text,{style:[H.quickAmountText,{color:c.card.titleColor,fontFamily:w.medium}],children:[Ti,$.toLocaleString()]})},$))}),j&&jsx(Text,{style:[H.validationError,{color:b.error,fontFamily:w.regular}],children:j}),jsxs(View,{style:H.providerSection,children:[jsxs(View,{style:H.providerHeader,children:[jsx(Text,{style:[H.providerLabel,{color:c.card.labelColor,fontFamily:w.medium}],children:"Provider"}),R.length>0&&!E&&jsxs(Text,{style:[H.refreshText,{color:c.card.labelRightColor,fontFamily:w.regular}],children:["Refreshing in ",pe,"s"]})]}),jsx(Gt,{cardTokens:c.depositCard.quoteProvider.card,onPress:E||R.length===0?void 0:()=>ir(true),contentStyle:StyleSheet.flatten([H.providerButton,(E||R.length===0)&&H.disabled]),children:E?jsxs(View,{style:H.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:c.container.subtitleColor}),jsx(Text,{style:[H.loadingText,{color:c.container.subtitleColor,fontFamily:w.regular}],children:"Finding best rates..."})]}):G?jsxs(View,{style:H.providerContent,children:[jsxs(View,{style:H.providerInfo,children:[he&&jsx(Text,{style:[H.autoPickedText,{color:c.container.subtitleColor,fontFamily:w.regular}],children:"Auto-picked for you"}),jsxs(View,{style:H.providerRow,children:[jsx(Image,{source:{uri:Z(Sa(G.icon_urls,"png",G.icon_url))},style:H.providerIconImage},`provider-${G.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[H.providerName,{color:c.card.titleColor,fontFamily:w.medium}],children:G.service_provider_display_name}),jsxs(Text,{style:[H.bestPriceText,{color:b.success,fontFamily:w.regular}],children:["Best price \u2022 ",G.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(Vr,{size:20,color:c.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[H.noProviderText,{color:c.container.subtitleColor,fontFamily:w.regular}],children:parseFloat(S)>0?"No providers available":"Enter an amount to see providers"})}),P&&jsx(Text,{style:[H.errorText,{color:b.error,fontFamily:w.regular}],children:P})]}),jsxs(ct,{visible:Or,onClose:()=>ir(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:h?.providerModal?.borderTopLeftRadius??g,borderTopRightRadius:h?.providerModal?.borderTopRightRadius??k,children:[jsx(kr,{title:"Select Provider",showBack:false,onClose:()=>ir(false)}),jsx(BottomSheetScrollView,{style:H.providerModalList,contentContainerStyle:H.providerModalListContent,showsVerticalScrollIndicator:false,children:jsx(View,{style:H.quotesList,children:[...R].sort(($,ie)=>ie.destination_amount-$.destination_amount).map(($,ie)=>{let wt=G?.service_provider===$.service_provider,Dr=ie===0;return jsxs(Gt,{cardTokens:c.depositCard.quoteProvider.card,onPress:()=>{Se($),Te(true),Ie($.service_provider===Ge),ir(false);},contentStyle:StyleSheet.flatten([H.quoteItem,wt&&{borderWidth:2,borderColor:b.primary}]),children:[jsxs(View,{style:H.quoteLeft,children:[jsx(Image,{source:{uri:Z(Sa($.icon_urls,"png",$.icon_url))},style:H.providerIconImage}),jsxs(View,{children:[jsx(Text,{style:[H.quoteName,{color:c.card.titleColor,fontFamily:w.medium}],children:$.service_provider_display_name}),Dr&&jsx(Text,{style:[H.bestPriceLabel,{color:b.success,fontFamily:w.regular}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:H.quoteRight,children:[jsxs(Text,{style:[H.quoteAmount,{color:c.card.textRightColor,fontFamily:w.medium}],children:[$.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[H.quoteSource,{color:c.card.subtextRightColor,fontFamily:w.regular}],children:["Fee: ",Ti,$.total_fee.toFixed(2)]})]})]},$.service_provider)})})})]})]}),jsx(View,{style:[H.continueButtonContainer,{backgroundColor:b.background}],children:jsx(View,{style:{opacity:E||Ee||!G||parseFloat(S)<=0?.5:1},children:jsx(TouchableOpacity$1,{onPress:yo,disabled:E||Ee||!G||parseFloat(S)<=0,style:[H.continueButton,{backgroundColor:c.container.buttonColor,borderRadius:c.button.borderRadius,borderWidth:c.button.borderWidth,borderColor:c.button.borderColor}],children:jsx(Text,{style:[H.continueButtonText,{color:c.container.buttonTitleColor,fontFamily:w.medium}],children:Ee?"Loading...":"Continue"})})})})]}),Mo()]}):re==="onramp"&&et?jsxs(View,{style:H.onrampContainer,children:[jsx(Image,{source:{uri:Z(Sa(et.provider.icon_urls,"png",et.provider.icon_url))},style:H.onrampProviderIcon}),jsxs(Text,{style:[H.onrampTitle,{color:c.container.titleColor,fontFamily:w.medium}],children:["Complete transaction with ",et.provider.service_provider_display_name]}),jsx(Text,{style:[H.onrampSubtitle,{color:c.container.subtitleColor,fontFamily:w.regular}],children:"You can close this modal."}),jsxs(View,{style:[H.flowDiagram,{backgroundColor:c.card.backgroundColor}],children:[jsxs(View,{style:H.flowStep,children:[jsx(Image,{source:{uri:Ht(`/icons/currencies/png/${et.sourceCurrency.toLowerCase()}.png`)},style:H.flowIconImage}),jsx(Text,{style:[H.flowLabel,{color:c.card.subtitleColor,fontFamily:w.regular}],children:"You use"}),jsx(Text,{style:[H.flowValue,{color:c.card.titleColor,fontFamily:w.medium}],children:et.sourceCurrency.toUpperCase()})]}),jsx(Vr,{size:16,color:c.card.actionColor,strokeWidth:2}),jsxs(View,{style:H.flowStep,children:[jsxs(View,{style:H.flowIconWithBadge,children:[jsx(Image,{source:{uri:Di(ze?.destination_token_metadata?.icon_urls,"png")||ze?.destination_token_metadata?.icon_url||Ht("/icons/tokens/png/usdc.png")},style:H.flowIconImageNoBadge}),jsx(Image,{source:{uri:Di(ze?.destination_token_metadata?.chain?.icon_urls,"png")||ze?.destination_token_metadata?.chain?.icon_url||Ht("/icons/networks/png/polygon.png")},style:[H.flowNetworkBadge,{borderColor:b.background,borderRadius:c.badge.borderRadius}]})]}),jsx(Text,{style:[H.flowLabel,{color:c.card.subtitleColor,fontFamily:w.regular}],children:"You buy"}),jsx(Text,{style:[H.flowValue,{color:c.card.titleColor,fontFamily:w.medium}],children:"USDC"})]}),jsx(Vr,{size:16,color:c.card.actionColor,strokeWidth:2}),jsxs(View,{style:H.flowStep,children:[jsxs(View,{style:H.flowIconWithBadge,children:[jsx(Image,{source:{uri:ft||Ht("/icons/tokens/png/usdc.png")},style:H.flowIconImageNoBadge}),jsx(Image,{source:{uri:Fe||Ht("/icons/networks/png/polygon.png")},style:[H.flowNetworkBadge,{borderColor:b.background,borderRadius:c.badge.borderRadius}]})]}),jsx(Text,{style:[H.flowLabel,{color:c.card.subtitleColor,fontFamily:w.regular}],children:"You receive"}),jsx(Text,{style:[H.flowValue,{color:c.card.titleColor,fontFamily:w.medium}],children:O})]})]}),jsx(View,{style:[H.onrampInfoBox,{backgroundColor:c.card.backgroundColor,borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor}],children:jsx(Text,{style:[H.onrampInfoText,{color:c.card.descriptionColor,fontFamily:w.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 vg({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:a,borderTopLeftRadius:i,borderTopRightRadius:s}){return jsxs(ct,{visible:e,onClose:t,closeOnBackdropPress:false,enablePanDownToClose:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:fi.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:fi.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(qe,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[fi.headerTitle,{color:n.foreground,fontFamily:a.medium}],children:o}),jsx(View,{style:fi.headerSpacer})]}),r&&jsx(View,{style:fi.container,children:jsx(WebView,{source:{uri:r},style:fi.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:fi.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var fi=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"}}),H=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"},bestPriceLabel:{fontSize:11,marginTop:2},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 Fg(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 Vg(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Cl({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=V(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=Z(ge(e.destination_token_metadata,"png")||Ht("/icons/tokens/png/usdc.png")),m=i?"Deposit Processing":"Deposit Completed",d=Fg(e.created_at||new Date().toISOString()),g=Vg(e.source_amount_usd);return jsxs(Gt,{cardTokens:a,onPress:t,contentStyle:rn.container,children:[jsxs(View,{style:rn.iconContainer,children:[jsx(Image,{source:{uri:l},style:rn.tokenIcon}),jsx(View,{style:[rn.statusBadge,{backgroundColor:i?r.warning:r.success,borderColor:a.backgroundColor}],children:i?jsx(ha,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(qe,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:rn.textContainer,children:[jsx(Text,{style:[rn.title,{color:a.titleColor,fontFamily:o.medium}],children:m}),jsx(Text,{style:[rn.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:d})]}),jsxs(View,{style:rn.rightContainer,children:[jsx(Text,{style:[rn.amount,{color:a.textRightColor,fontFamily:o.medium}],children:g}),jsx(Vr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var rn=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 tm(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 rm(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 Bg(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var om=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function nm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function Wg(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 Ag({count:e=4}){let{colors:t,components:r}=V(),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:hi.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[hi.row,{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius??12,borderWidth:n.borderWidth,borderColor:n.borderColor}],children:[jsx(Animated.View,{style:[hi.icon,{backgroundColor:a,opacity:o}]}),jsxs(View,{style:hi.textBlock,children:[jsx(Animated.View,{style:[hi.titleBar,{backgroundColor:a,opacity:o}]}),jsx(Animated.View,{style:[hi.subtitleBar,{backgroundColor:a,opacity:o}]})]}),jsx(Animated.View,{style:[hi.amountBar,{backgroundColor:a,opacity:o}]})]},s))})}var hi=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 Cd({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{colors:a,fonts:i,components:s}=V(),[l,m]=useState(r),[d,g]=useState(false),[k,h]=useState(null),[b,w]=useState(false),c=useRef(null);useEffect(()=>{if(!e||!o)return;let T=async()=>{g(true);try{let B=[...(await No(o,n)).data].sort((E,D)=>{let P=E.created_at?new Date(E.created_at).getTime():0;return (D.created_at?new Date(D.created_at).getTime():0)-P});m(B);}catch(R){console.error("Failed to fetch executions:",R),m(r);}finally{g(false);}};T();let C=setInterval(T,1e4);return ()=>clearInterval(C)},[e,o,n,r]),useEffect(()=>{r.length>0&&m(T=>{let C=new Set(T.map(B=>B.id)),R=r.filter(B=>!C.has(B.id));return R.length>0?[...R,...T]:T});},[r]),useEffect(()=>{e||h(null);},[e]);let S=T=>{h(T);},y=()=>{h(null),w(false);},u=()=>{h(null),t();},f=()=>{if(!k)return null;let T=k,C=T.status==="pending"||T.status==="waiting"||T.status==="delayed",R=T.status==="succeeded",B=Z(ge(T.destination_token_metadata,"png")||Ht("/icons/tokens/png/usdc.png")),E=T.provider_metadata?.details,D=E?.currencyIn,P=E?.currencyOut;D?.currency?.symbol||"USDC";P?.currency?.symbol||"USDC";let fe=rm(T.source_amount_base_unit,T.source_token_metadata?.decimals),Ke=rm(T.destination_amount_base_unit,T.destination_token_metadata?.decimals),De=Bg(T.source_amount_usd),G=tm(T.source_chain_type,T.source_chain_id),Se=tm(T.destination_chain_type,T.destination_chain_id),he=()=>{T.explorer_url&&Linking.openURL(T.explorer_url);},Ie=()=>{T.destination_explorer_url&&Linking.openURL(T.destination_explorer_url);};return jsxs(BottomSheetScrollView,{ref:c,style:le.scrollContainer,contentContainerStyle:le.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:le.iconSection,children:[jsxs(View,{style:le.iconWrapper,children:[jsx(Image,{source:{uri:B},style:le.tokenIcon}),jsx(View,{style:[le.statusBadge,{backgroundColor:C?a.warning:a.success,borderColor:a.background}],children:C?jsx(Pt,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(qe,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:le.statusRow,children:[jsx(View,{style:[le.statusDot,{backgroundColor:C?a.warning:a.success}]}),jsx(Text,{style:[le.statusText,{color:s.container.titleColor,fontFamily:i.semibold}],children:C?"Processing":"Completed"})]}),jsx(Text,{style:[le.dateText,{color:s.container.subtitleColor,fontFamily:i.regular}],children:Wg(T.created_at||new Date().toISOString())})]}),jsxs(View,{style:[le.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Sent"}),jsxs(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[fe," ",nm(T.source_currency)]})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Received"}),jsxs(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[Ke," ",nm(T.destination_currency)]})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"USD Value"}),jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:De})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Source Network"}),jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:G})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Destination Network"}),jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Se})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let Ge=!b;w(Ge),Ge?setTimeout(()=>{c.current?.scrollToEnd({animated:true});},100):c.current?.scrollTo({y:0,animated:true});},style:le.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[le.toggleText,{color:s.container.actionTitle,fontFamily:i.regular}],children:b?"See less":"See more details"}),b?jsx(wo,{size:14,color:s.container.actionColor,strokeWidth:2}):jsx(Pt,{size:14,color:s.container.actionColor,strokeWidth:2})]}),b&&jsxs(View,{style:[le.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[T.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:he,style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Deposit Tx"}),jsxs(View,{style:le.cardRowRight,children:[jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:om(T.transaction_hash)}),jsx(Co,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]})]}),T.destination_explorer_url&&R&&jsxs(TouchableOpacity,{onPress:Ie,style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Completion Tx"}),jsxs(View,{style:le.cardRowRight,children:[jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:om(T.destination_transaction_hashes[0])}),jsx(Co,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]})]})]})},x=d&&l.length===0;return jsxs(Fragment,{children:[jsx(kr,{title:k?"Deposit Details":"Deposit Tracker",onClose:u,showClose:!k,showBack:!!k,onBack:y}),k?f():x?jsx(Ag,{}):jsx(BottomSheetScrollView,{style:le.scrollContainer,contentContainerStyle:le.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:le.emptyContainer,children:[jsx(Text,{style:[le.emptyText,{color:s.container.titleColor,fontFamily:i.medium}],children:"No deposits yet"}),jsx(Text,{style:[le.emptySubtext,{color:s.container.subtitleColor,fontFamily:i.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:le.executionsList,children:l.map(T=>jsx(Cl,{execution:T,onPress:()=>S(T)},T.id))})})]})}var le=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,a]=useState(null),[i,s]=useState(false),[l,m]=useState(false),[d,g]=useState(null),[k,h]=useState(null);useEffect(()=>{!t||r||(s(true),Is().then(S=>{o(S),g(null);}).catch(S=>{g(S instanceof Error?S:new Error(String(S)));}).finally(()=>{s(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(m(true),Rs(e).then(S=>{a(S),h(null);}).catch(S=>{h(S instanceof Error?S:new Error(String(S)));}).finally(()=>{m(false);}));},[t,e,n]);let b=i||l,w=d||k||null,c=null;if(r&&n){let S=n.blocked_country_codes||[],y=r.alpha2.toUpperCase();c=!S.some(u=>u.toUpperCase()===y);}return {isAllowed:c,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:b,error:w}}var kd="unifold_recent_tokens",Hg=5,dm=[{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 xl(){try{let e=await kc.getItem(kd);return e?JSON.parse(e):[]}catch{return []}}async function Ng(e){try{let r=(await xl()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,Hg);await kc.setItem(kd,JSON.stringify(o));}catch{}}async function jg(e){try{let r=(await xl()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await kc.setItem(kd,JSON.stringify(r)),r}catch{return []}}function Td({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:d}=V(),[g,k]=useState(""),[h,b]=useState([]);useEffect(()=>{e&&xl().then(b);},[e]),useEffect(()=>{e||k("");},[e]);let w=useMemo(()=>{let x=[];return r.forEach(_=>{_.chains.forEach(T=>{x.push({token:_,chain:T});});}),x},[r]),c=useMemo(()=>{let x=[],_=new Set,T=(C,R,B,E)=>{let D=`${C}-${R}:${B}`;if(_.has(D))return;let P=r.find(j=>j.symbol===C);if(!P)return;let q=P.chains.find(j=>j.chain_type===R&&j.chain_id===B);q&&(_.add(D),x.push({token:P,chain:q,isRecent:E}));};return h.forEach(C=>{T(C.symbol,C.chainType,C.chainId,true);}),dm.forEach(C=>{T(C.symbol,C.chainType,C.chainId,false);}),x},[r,h]),S=useMemo(()=>{if(!g.trim())return w;let x=g.toLowerCase();return w.filter(({token:_,chain:T})=>_.symbol.toLowerCase().includes(x)||_.name.toLowerCase().includes(x)||T.chain_name.toLowerCase().includes(x))},[w,g]),y=(x,_,T)=>dm.some(C=>C.symbol===x&&C.chainType===_&&C.chainId===T),u=async(x,_)=>{let T=`${_.chain_type}:${_.chain_id}`;if(!y(x.symbol,_.chain_type,_.chain_id)){await Ng({symbol:x.symbol,chainType:_.chain_type,chainId:_.chain_id});let C=await xl();b(C);}k(""),a(x.symbol,T),t();},f=async(x,_)=>{let T=await jg({symbol:x.symbol,chainType:_.chain_type,chainId:_.chain_id});b(T);};return jsxs(ct,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,startExpanded:false,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:it.header,children:[jsx(View,{style:it.headerSpacer}),jsx(Text,{style:[it.headerTitle,{color:d.header.titleColor,fontFamily:m.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:it.closeButton,children:jsx(tt,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:it.searchContainer,children:jsx(TextInput,{style:[it.searchInput,{backgroundColor:d.search.backgroundColor,color:d.search.inputColor,fontFamily:m.regular,borderRadius:d.input.borderRadius,borderWidth:d.input.borderWidth,borderColor:d.input.borderColor}],placeholder:"Search",placeholderTextColor:d.search.placeholderColor,value:g,onChangeText:k,autoCapitalize:"none",autoCorrect:false})}),c.length>0&&!g&&jsxs(View,{style:it.quickSelectSection,children:[jsx(Text,{style:[it.sectionLabel,{color:d.list.titleSectionColor,fontFamily:m.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:it.quickSelectScroll,children:c.map(({token:x,chain:_,isRecent:T})=>{let C=`${_.chain_type}:${_.chain_id}`;x.symbol===o&&C===n;return jsxs(View,{children:[T&&jsx(TouchableOpacity$1,{onPress:()=>f(x,_),style:it.removeButton,children:jsx(tt,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>u(x,_),activeOpacity:.7,style:[it.quickSelectItem,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:it.tokenIconContainer,children:[jsx(Image,{source:{uri:Z(ge(x,"png"))},style:it.quickSelectIcon}),jsx(Image,{source:{uri:Z(ge(_,"png"))},style:[it.quickSelectChainBadge,{borderColor:d.card.backgroundColor,borderRadius:d.badge.borderRadius}]})]}),jsxs(View,{style:it.quickSelectText,children:[jsx(Text,{style:[it.quickSelectSymbol,{color:d.card.titleColor,fontFamily:m.medium}],children:x.symbol}),jsx(Text,{style:[it.quickSelectChain,{color:d.card.subtitleColor,fontFamily:m.regular}],children:_.chain_name})]})]})]},`quick-${x.symbol}-${C}`)})})]}),jsx(Text,{style:[it.sectionLabel,{color:d.list.titleSectionColor,fontFamily:m.regular}],children:"All supported tokens"}),jsx(BottomSheetScrollView,{style:it.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:it.tokenListContent,children:S.length===0?jsx(View,{style:it.emptyState,children:jsx(Text,{style:[it.emptyText,{color:l.foregroundMuted,fontFamily:m.regular}],children:"No tokens found"})}):S.map(({token:x,chain:_})=>{let T=`${_.chain_type}:${_.chain_id}`,C=x.symbol===o&&T===n;return jsxs(TouchableOpacity$1,{onPress:()=>u(x,_),activeOpacity:.7,style:[it.tokenItem,{backgroundColor:C?d.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:it.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:Z(ge(x,"png"))},style:it.tokenIcon}),jsx(Image,{source:{uri:Z(ge(_,"png"))},style:[it.tokenChainBadge,{borderColor:d.card.backgroundColor,borderRadius:d.badge.borderRadius}]})]}),jsxs(View,{style:it.tokenInfo,children:[jsx(Text,{style:[it.tokenSymbol,{color:d.card.titleColor,fontFamily:m.medium}],children:x.symbol}),jsx(Text,{style:[it.tokenChainName,{color:d.card.subtitleColor,fontFamily:m.regular}],children:_.chain_name})]}),jsxs(Text,{style:[it.minDeposit,{color:d.card.labelColor,fontFamily:m.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:d.card.labelHighlightRightColor,fontFamily:m.regular},children:["$",_.minimum_deposit_amount_usd]})]})]},`${x.symbol}-${T}`)})})]})}var it=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 Rl=(e,t)=>`${t}:${e}`,Gg=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function xd({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:d="auto_ui",onExecutionsChange:g,onDepositSuccess:k,onDepositError:h,wallets:b,borderTopLeftRadius:w,borderTopRightRadius:c,sheetBorderRadius:S}){let{colors:y,fonts:u,components:f}=V(),x=s&&l?`${s}:${l}`:"solana:mainnet",[_,T]=useState("USDC"),[C,R]=useState(x),[B,E]=useState([]),[D,P]=useState(!b?.length),q=b?.length?b:B,[j,fe]=useState([]),[Ke,De]=useState(true),[G,Se]=useState(false),[he,Ie]=useState(false),[Ge,ke]=useState(false),[Y,Te]=useState([]),[st,We]=useState(new Map),[Ye]=useState(()=>new Date),[Ae,Ee]=useState(null),[Me,pe]=useState(false),[ee,be]=useState(null),[pt,M]=useState(false),W=new Map;j.forEach(xe=>{xe.chains.forEach(at=>{let N=`${at.chain_type}:${at.chain_id}`;W.has(N)||W.set(N,at);});});let se=Array.from(W.values()),oe=Gg(C),ve=se.find(xe=>xe.chain_type===oe.chainType&&xe.chain_id===oe.chainId),xt=ve?.chain_type||"ethereum",ce=Ho(q,xt),ae=ce?.address||"",ze=useRef(false);useEffect(()=>{async function xe(){try{De(!0),Ee(null);let N=await Nn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(fe(N.data),N.data.length>0&&!ze.current){ze.current=!0;let re,_e;if(s&&l)if(m)for(let ue of N.data){let ne=ue.chains.find(O=>O.chain_type===s&&O.chain_id===l&&O.token_address.toLowerCase()===m.toLowerCase());if(ne){re=ue,_e=ne;break}}else for(let ue of N.data){let ne=ue.chains.find(O=>O.chain_type===s&&O.chain_id===l);if(ne){re=ue,_e=ne;break}}if(!re&&a)for(let ue of N.data){let ne=ue.chains.find(O=>O.token_address.toLowerCase()===a.toLowerCase());if(ne){re=ue,_e=ne;break}}re||(re=N.data.find(ue=>ue.symbol==="USDC"),re&&re.chains.length>0&&(_e=re.chains[0])),re||(re=N.data.find(ue=>ue.symbol==="USDT"),re&&re.chains.length>0&&(_e=re.chains[0])),re||(re=N.data[0],re.chains.length>0&&(_e=re.chains[0])),re&&T(re.symbol),_e&&R(Rl(_e.chain_id,_e.chain_type));}}catch(at){console.error("Error fetching supported tokens:",at),Ee("Failed to load supported tokens"),h?.({message:"Failed to load supported tokens",error:at});}finally{De(false);}}xe();},[t,a,n,o,s,l,m,h]),useEffect(()=>{g&&g(Y);},[Y,g]),useEffect(()=>{if(b?.length){P(false);return}if(B.length>0){P(false);return}let xe=null,at=false,N=async()=>{if(!at){P(true);try{let re=await Uo({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);at||(E(re.data),Ee(null),P(!1));}catch(re){console.error("Error fetching wallets, retrying in 5s:",re),at||(Ee(re instanceof Error?re.message:"Failed to load wallets"),P(false),xe=setTimeout(N,5e3));}}};return N(),()=>{at=true,xe&&clearTimeout(xe);}},[e,r,o,n,a,t,b,B.length]);let Yt=ce?.id??"",{showWaitingUi:mt,handleIveDeposited:de}=ea({depositConfirmationMode:d,depositAddress:ae,chain:C,externalUserId:e,publishableKey:t,modalOpenedAt:Ye,depositWalletId:Yt,depositExecutions:Y,trackedExecutions:st,setDepositExecutions:Te,setTrackedExecutions:We,setLatestExecution:be,setShowStatusSheet:pe,onDepositSuccess:k,onExecutionsChange:g,onDepositError:h});useEffect(()=>{if(!j.length)return;let xe=j.find(N=>N.symbol===_);if(!xe||xe.chains.length===0)return;if(!xe.chains.some(N=>Rl(N.chain_id,N.chain_type)===C)){let N=xe.chains[0];R(Rl(N.chain_id,N.chain_type));}},[_,j,C]);let et=j.find(xe=>xe.symbol===_),_t=(et?.chains||[]).find(xe=>Rl(xe.chain_id,xe.chain_type)===C),io=async()=>{if(ae)try{Clipboard.setString(ae),Se(!0),setTimeout(()=>Se(!1),2e3);}catch(xe){console.error("Failed to copy:",xe);}},Or=_t?.estimated_price_impact_percent??0,ir=_t?.max_slippage_percent??.25,$t=_t?.minimum_deposit_amount_usd??3;return Ke?jsxs(View,{style:z.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:y.primary}),jsx(Text,{style:[z.loadingText,{color:y.foregroundMuted,fontFamily:u.regular}],children:"Loading currencies..."})]}):Ae&&j.length===0?jsxs(View,{style:z.errorContainer,children:[jsx(Text,{style:[z.errorText,{color:y.error,fontFamily:u.regular}],children:Ae}),jsx(Text,{style:[z.errorHint,{color:y.foregroundMuted,fontFamily:u.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:z.container,children:[jsxs(View,{style:z.selectorSection,children:[jsx(Text,{style:[z.selectorLabel,{color:f.card.labelColor,fontFamily:u.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>ke(true),disabled:Ke||j.length===0,style:[z.tokenSelectorButton,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],activeOpacity:.7,children:Ke?jsxs(View,{style:z.tokenSelectorLoading,children:[jsx(View,{style:[z.loadingIcon,{backgroundColor:y.cardHover}]}),jsxs(View,{style:z.loadingTextContainer,children:[jsx(View,{style:[z.loadingLine,{backgroundColor:y.cardHover,width:60}]}),jsx(View,{style:[z.loadingLine,{backgroundColor:y.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:z.tokenIconWrapper,children:[et&&jsx(Image,{source:{uri:Z(ge(et,"png"))},style:z.tokenMainIcon}),(_t||ve)&&jsx(Image,{source:{uri:Z(ge(_t||ve,"png"))},style:[z.tokenChainBadge,{borderColor:f.card.backgroundColor,borderRadius:f.badge.borderRadius}]})]}),jsxs(View,{style:z.tokenSelectorInfo,children:[jsx(Text,{style:[z.tokenSelectorSymbol,{color:f.card.titleColor,fontFamily:u.semibold}],children:et?.symbol||_}),jsx(Text,{style:[z.tokenSelectorNetwork,{color:f.card.subtitleColor,fontFamily:u.regular}],numberOfLines:1,children:_t?.chain_name||ve?.chain_name||"Select network"})]}),jsxs(View,{style:z.tokenSelectorRight,children:[jsxs(Text,{style:[z.minDepositText,{color:f.card.labelHighlightRightColor,fontFamily:u.medium}],children:["$",$t," min"]}),jsx(Vr,{size:16,color:f.card.actionColor,strokeWidth:2})]})]})})]}),jsx(Td,{visible:Ge,onClose:()=>ke(false),tokens:j,selectedToken:_,selectedChainKey:C,onSelect:(xe,at)=>{T(xe),R(at);},borderTopLeftRadius:S?.tokenSelector?.borderTopLeftRadius??w,borderTopRightRadius:S?.tokenSelector?.borderTopRightRadius??c}),jsx(View,{style:z.qrContainer,children:jsx(View,{style:[z.qrWrapper,{backgroundColor:y.background,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth>0?f.card.borderWidth:1,borderColor:f.card.borderColor}],children:D?jsxs(View,{style:z.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:y.primary}),jsx(Text,{style:[z.loadingText,{color:y.foregroundMuted,fontFamily:u.regular}],children:"Loading..."})]}):ae?jsx(ss,{value:ae,size:180,logoUri:Z(ge(_t,"png")||Ht("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:z.qrLoading,children:jsx(Text,{style:[z.errorText,{color:y.error,fontFamily:u.regular}],children:"No address available"})})})}),jsxs(View,{style:z.addressSection,children:[jsxs(View,{style:z.addressHeader,children:[jsx(Text,{style:[z.addressLabel,{color:f.card.labelColor,fontFamily:u.medium}],children:"Deposit Address"}),G&&jsxs(View,{style:z.copiedIndicator,children:[jsx(qe,{size:14,color:y.success,strokeWidth:2}),jsx(Text,{style:[z.copiedText,{color:y.success,fontFamily:u.regular}],children:"Copied"})]})]}),jsxs(Gt,{cardTokens:f.transferCrypto.depositAddress.card,onPress:!D&&ae?io:void 0,contentStyle:z.addressBox,children:[jsx(Text,{style:[z.addressText,{color:f.card.titleColor,fontFamily:u.regular}],numberOfLines:2,children:D?"Loading...":ae||"No address available"}),jsx(View,{style:z.addressCopyIcon,children:jsx(Hn,{size:16,color:f.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[z.detailsCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Ie(!he),style:z.detailsHeader,children:[jsxs(View,{style:z.detailsRow,children:[jsx(View,{style:[z.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(bo,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[z.detailsLabel,{color:f.card.titleColor,fontFamily:u.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:z.chevronContainer,children:he?jsx(wo,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(Pt,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),he&&jsxs(View,{style:z.detailsContent,children:[jsxs(View,{style:z.detailsRow,children:[jsx(View,{style:[z.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[z.detailsLabel,{color:f.card.titleColor,fontFamily:u.regular}],children:["Price impact: ",Or.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>M(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ii,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:z.detailsRow,children:[jsx(View,{style:[z.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[z.detailsLabel,{color:f.card.titleColor,fontFamily:u.regular}],children:["Slippage: Auto \u2022 ",ir.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>M(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ii,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:z.detailsRow,children:[jsx(View,{style:[z.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fa,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[z.detailsLabel,{color:f.card.titleColor,fontFamily:u.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(ll,{depositConfirmationMode:d,depositAddress:ae,showWaitingUi:mt,latestExecution:ee,onIveDeposited:de}),jsx(TouchableOpacity$1,{style:z.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[z.termsText,{color:y.primary,fontFamily:u.regular}],children:"Terms apply"})}),jsxs(ct,{visible:pt,onClose:()=>M(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:S?.infoSheet?.borderTopLeftRadius??w,borderTopRightRadius:S?.infoSheet?.borderTopRightRadius??c,children:[jsxs(View,{style:[z.sheetHeader,{borderBottomColor:y.border}],children:[jsx(View,{style:z.sheetHeaderSpacer}),jsx(Text,{style:[z.sheetTitle,{color:f.header.titleColor,fontFamily:u.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>M(false),style:z.sheetCloseButton,children:jsx(tt,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:z.infoSheetContent,children:[jsxs(View,{style:[z.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:z.infoCardHeader,children:[jsx(View,{style:[z.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(mn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[z.infoCardTitle,{color:f.card.titleColor,fontFamily:u.medium}],children:"Price Impact"}),jsxs(Text,{style:[z.infoCardValue,{color:f.card.titleColor,fontFamily:u.medium}],children:[Or.toFixed(2),"%"]})]}),jsx(Text,{style:[z.infoCardDescription,{color:f.card.descriptionColor,fontFamily:u.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:[z.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:z.infoCardHeader,children:[jsx(View,{style:[z.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[z.infoCardTitle,{color:f.card.titleColor,fontFamily:u.medium}],children:"Max Slippage"}),jsxs(Text,{style:[z.infoCardValue,{color:f.card.titleColor,fontFamily:u.medium}],children:[ir.toFixed(2),"%"]})]}),jsx(Text,{style:[z.infoCardDescription,{color:f.card.descriptionColor,fontFamily:u.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."})]})]})]}),ee&&jsx(as,{visible:Me,status:ee.status,tokenIconUrl:ee.destination_token_metadata?.icon_urls?.find(xe=>xe.format==="png")?.url||ee.destination_token_metadata?.icon_url||ge(et,"png"),explorerUrl:ee.explorer_url,completionExplorerUrl:ee.destination_explorer_url,date:ee.created_at?new Date(ee.created_at):void 0,amountUsd:ee.source_amount_usd?parseFloat(ee.source_amount_usd):void 0,onClose:()=>pe(false),borderTopLeftRadius:S?.depositStatus?.borderTopLeftRadius??w,borderTopRightRadius:S?.depositStatus?.borderTopRightRadius??c})]})}var z=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 sn={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 ey(){let{colors:e,components:t}=V(),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:[zn.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[zn.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:zn.textBlock,children:[jsx(Animated.View,{style:[zn.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[zn.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:zn.rightIcons,children:Array.from({length:i}).map((s,l)=>jsx(Animated.View,{style:[zn.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:zn.container,children:[jsx(a,{rightIcons:3}),jsx(a,{rightIcons:2}),jsx(a,{rightIcons:0})]})}var zn=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 ty({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,defaultChainType:d,defaultChainId:g,defaultTokenAddress:k,showBalance:h=false,hideDepositTracker:b=false,enableStripeLinkPay:w=false,StripeOnrampComponent:c,stripeOnrampEmail:S,stripeOnrampPhone:y,stripeMerchantIdentifier:u,stripePaymentSelectorPosition:f,stripeSkipSuccessConfirmation:x,stripeTheme:_,depositConfirmationMode:T="auto_ui",transferInputVariant:C="double_input",initialScreen:R="main",onDepositSuccess:B,onDepositError:E,sheetBorderRadius:D}){let P=D?.globalBorderTopLeftRadius,q=D?.globalBorderTopRightRadius,{colors:j,fonts:fe}=V(),[Ke,De]=useState([]),[G,Se]=useState(null),[he,Ie]=useState("amount"),Ge=R==="tracker"&&!b?"tracker":R==="transfer"?"transfer":R==="card"?"card":"main",ke=Ge==="main",[Y,Te]=useState(Ge),{isAllowed:st,isLoading:We}=na(o,e);useEffect(()=>{if(!e||G)return;let ce=false;return Rs(o).then(async ae=>{if(ce)return;let ze=[];for(let Yt of ae?.transfer_crypto?.networks??[]){let mt=Yt.icon_urls.find(de=>de.format==="png")?.url||Yt.icon_urls.find(de=>de.format==="svg")?.url;mt&&ze.push(Z(mt));}for(let Yt of ae?.payment_networks?.networks??[]){let mt=Yt.icon_urls.find(de=>de.format==="png")?.url||Yt.icon_urls.find(de=>de.format==="svg")?.url;mt&&ze.push(Z(mt));}ze.length>0&&await Gc(ze),ce||Se(ae);}).catch(console.error),()=>{ce=true;}},[e,G,o]);let Ye=()=>{t();};useEffect(()=>{e&&(Te(Ge),Ie("amount"));},[e,Ge]);let Ae=useCallback(()=>{ke?(Te("main"),Ie("amount")):Ye();},[ke,Ye]),Ee=Ke.filter(ce=>ce.status==="pending"||ce.status==="waiting").length,pe=!!(i&&s&&l&&m&&o)&&h!==false&&!!G,ee=We||e&&!G,be=st===false,pt=null;if(Y==="stripe"&&c){let ce=jsx(c,{publishableKey:o,email:S,phone:y,externalUserId:r,recipientAddress:i??"",destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,merchantIdentifier:u,paymentSelectorPosition:f,skipSuccessConfirmation:x,onClose:Ae});pt=_?jsx(vi,{..._,children:ce}):ce;}let M=Y==="stripe"?1:Y==="transfer"||Y==="card"?.94:Y==="tracker"?.6:Y==="main"?.5:void 0,W=Y==="tracker"||Y==="main"?.9:void 0,oe={main:D?.main,transfer:D?.transferCrypto,card:D?.buyWithCard,stripe:{borderTopLeftRadius:0,borderTopRightRadius:0},tracker:D?.depositsTracker}[Y],ve=oe?.borderTopLeftRadius??P,xt=oe?.borderTopRightRadius??q;return jsxs(ct,{visible:e,onClose:Y==="main"?Ye:Ae,closeOnBackdropPress:false,enablePanDownToClose:Y==="tracker"||Y==="main",showHandle:Y==="tracker"||Y==="main",heightPercent:M,maxHeightPercent:W,borderTopLeftRadius:ve,borderTopRightRadius:xt,children:[Y==="main"&&jsxs(Fragment,{children:[jsx(kr,{title:n,showBack:false,onClose:Ye,showBalance:pe,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:G?.project_name}),ee&&jsx(ey,{}),!ee&&be&&jsxs(View,{style:br.centeredContainer,children:[jsx(View,{style:[br.iconContainer,{backgroundColor:j.cardHover}],children:jsx(ks,{size:32,color:j.foreground,strokeWidth:1.5})}),jsx(Text,{style:[br.blockedTitle,{color:j.foreground,fontFamily:fe.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[br.blockedDescription,{color:j.foreground,opacity:.7,fontFamily:fe.regular}],children:"There are no supported tokens available from your current location."})]}),!ee&&!be&&jsxs(View,{style:br.optionsContainer,children:[jsx(Ks,{onPress:()=>Te("transfer"),title:sn.transferCrypto.title,subtitle:sn.transferCrypto.subtitle,featuredTokens:G?.transfer_crypto?.networks}),jsx(Ys,{onPress:()=>Te("card"),title:sn.depositWithCard.title,subtitle:sn.depositWithCard.subtitle,paymentNetworks:G?.payment_networks?.networks}),w&&c&&jsx(Xs,{onPress:()=>Te("stripe"),title:sn.stripeLinkPay.title,subtitle:sn.stripeLinkPay.subtitle}),!b&&jsx(Js,{onPress:()=>Te("tracker"),title:sn.depositTracker.title,subtitle:sn.depositTracker.subtitle,badge:Ee>0?Ee:void 0})]})]}),Y==="transfer"&&jsxs(Fragment,{children:[jsx(kr,{title:sn.transferCrypto.title,showBack:false,onClose:Ae,showBalance:pe,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:G?.project_name}),We&&jsx(View,{style:[br.centeredContainer,br.centeredFlex],children:jsx(ActivityIndicator,{color:j.foreground})}),!We&&be&&jsxs(View,{style:[br.centeredContainer,br.centeredFlex],children:[jsx(View,{style:[br.iconContainer,{backgroundColor:j.cardHover}],children:jsx(ks,{size:32,color:j.foreground,strokeWidth:1.5})}),jsx(Text,{style:[br.blockedTitle,{color:j.foreground,fontFamily:fe.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[br.blockedDescription,{color:j.foreground,opacity:.7,fontFamily:fe.regular}],children:"There are no supported tokens available from your current location."})]}),!We&&!be&&jsx(BottomSheetScrollView,{style:br.transferScrollContainer,contentContainerStyle:br.scrollContent,showsVerticalScrollIndicator:false,children:C==="single_input"?jsx(xd,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:d,defaultChainId:g,defaultTokenAddress:k,depositConfirmationMode:T,onExecutionsChange:De,onDepositSuccess:B,onDepositError:E,borderTopLeftRadius:P,borderTopRightRadius:q,sheetBorderRadius:{tokenSelector:D?.tokenSelector,infoSheet:D?.infoSheet,depositStatus:D?.depositStatus}}):jsx(dl,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:d,defaultChainId:g,defaultTokenAddress:k,depositConfirmationMode:T,onExecutionsChange:De,onDepositSuccess:B,onDepositError:E,borderTopLeftRadius:P,borderTopRightRadius:q,sheetBorderRadius:{tokenSelector:D?.tokenSelector,chainSelector:D?.chainSelector,infoSheet:D?.infoSheet,depositStatus:D?.depositStatus}})})]}),Y==="card"&&jsxs(Fragment,{children:[jsx(kr,{title:`Deposit ${a||"USDC"}`,showBack:he==="onramp",onBack:()=>Ie("amount"),onClose:Ae,showBalance:pe,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:G?.project_name}),jsx(View,{style:br.buyWithCardContainer,children:jsx(gl,{externalUserId:r,publishableKey:o,destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,onDepositSuccess:B,onDepositError:E,view:he,onViewChange:ce=>Ie(ce),borderTopLeftRadius:P,borderTopRightRadius:q,sheetBorderRadius:{providerModal:D?.providerModal,webView:D?.webView,currencyModal:D?.currencyModal}})})]}),Y==="stripe"&&pt&&jsx(View,{style:br.stripeLinkPayContainer,children:pt}),Y==="tracker"&&jsx(Cd,{active:Y==="tracker",onClose:Ae,executions:Ke,externalUserId:r,publishableKey:o})]})}function Pl({theme:e="auto",...t}){return jsx(ty,{...t})}var br=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 Ol(e,t=true){return Yo({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>Ta(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function Id(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:a,enabled:i=true}=e;return Yo({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,a],queryFn:async()=>{let l=await Nn(a),m=null,d=null,g=null,k=null,h,b,w,c=l.data.some(S=>S.chains.some(y=>{let u=y.chain_type===t&&y.chain_id===r&&y.token_address.toLowerCase()===o.toLowerCase();return u&&(m=y.minimum_deposit_amount_usd,d=y.estimated_processing_time,g=y.max_slippage_percent,k=y.estimated_price_impact_percent,w=y.chain_name,b=S),u}));if(b){let S=ge(b,"png");S&&(h=Z(S));}return {isSupported:c,minimumAmountUsd:m,estimatedProcessingTime:d,maxSlippagePercent:g,priceImpactPercent:k,errorMessage:c?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:h,chainName:w}},enabled:i&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function vd(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:a,enabled:i=true}=e;return Yo({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,a],queryFn:async()=>{let l=await xa(t,r,o,n,a);if(l.balance){let m=l.balance.token?.decimals??6,d=l.balance.token?.symbol??"",g=l.balance.amount,k=BigInt(g),h=BigInt(10**m),b=k/h,c=(k%h).toString().padStart(m,"0").replace(/0+$/,""),S=c?`${b}.${c}`:b.toString();return {balanceBaseUnit:g,balanceHuman:S,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:m,symbol:d}}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 oy=2500,ny=3e3,iy=6e4;function Pd({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:a}){let[i,s]=useState([]),[l,m]=useState(false),d=useRef(new Date),g=useRef(new Map),k=useRef(false),h=useRef(n),b=useRef(a);return useEffect(()=>{h.current=n;},[n]),useEffect(()=>{b.current=a;},[a]),useEffect(()=>{o&&!k.current&&(d.current=new Date,g.current.clear()),o||g.current.clear(),k.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let w=d.current,c=async()=>{try{let y=await No(e,t,"withdraw"),u=new Date(w.getTime()-iy),f=[...y.data].sort((C,R)=>{let B=C.created_at?new Date(C.created_at).getTime():0;return (R.created_at?new Date(R.created_at).getTime():0)-B}),x=["pending","waiting","delayed"],_=["succeeded","failed"],T=null;for(let C of f){let R=C.created_at?new Date(C.created_at):null;if(!R||R<u)continue;let B=g.current.get(C.id);if(!B){T=C;break}if(x.includes(B)&&_.includes(C.status)){T=C;break}}if(T){let C=T,R=C.created_at?new Date(C.created_at):null;if(!R||R<d.current)return;let B=g.current.get(C.id);g.current.set(C.id,C.status),s(E=>{let D=E.findIndex(P=>P.id===C.id);if(D>=0){let P=[...E];return P[D]=C,P}return [...E,C]}),C.status==="succeeded"&&(!B||x.includes(B))?h.current?.({message:"Withdrawal completed successfully",transaction:C}):C.status==="failed"&&B!=="failed"&&b.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:C});}}catch(y){console.error("Failed to fetch withdraw executions:",y),b.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:y});}};c();let S=setInterval(c,oy);return m(true),()=>{clearInterval(S),m(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let w=async()=>{try{await nc({deposit_wallet_id:r},t);}catch{}};w();let c=setInterval(w,ny);return ()=>clearInterval(c)},[o,r,t]),{executions:i,isPolling:l}}var Od=(e,t)=>`${t}:${e}`;function aa({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:d,chainPickerBorderTopRightRadius:g}){let{colors:k,fonts:h,components:b}=V(),[w,c]=useState(false),[S,y]=useState(false),u=b.card,f=t?e.find(C=>C.symbol===t):void 0,x=f?.chains||[],_=r?x.find(C=>Od(C.chain_id,C.chain_type)===r):void 0,T={backgroundColor:u.backgroundColor,borderRadius:u.borderRadius,borderWidth:u.borderWidth||1,borderColor:u.borderColor};return jsxs(View,{style:Qe.row,children:[jsxs(View,{style:Qe.col,children:[jsx(Text,{style:[Qe.label,{color:u.labelColor,fontFamily:h.medium}],children:i}),jsxs(TouchableOpacity,{style:[Qe.selectButton,T],onPress:()=>!a&&e.length>0&&c(true),activeOpacity:.7,disabled:a||e.length===0,children:[a?jsx(Text,{style:[Qe.placeholder,{color:u.subtitleColor,fontFamily:h.regular}],children:"Loading..."}):f?jsxs(View,{style:Qe.selectedItem,children:[jsx(Image,{source:{uri:Z(ge(f,"png"))},style:Qe.icon}),jsx(Text,{style:[Qe.selectedText,{color:u.titleColor,fontFamily:h.medium}],numberOfLines:1,children:f.symbol})]}):jsx(Text,{style:[Qe.placeholder,{color:u.subtitleColor,fontFamily:h.regular}],children:"Select receive token"}),jsx(Pt,{size:16,color:u.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:Qe.col,children:[jsx(Text,{style:[Qe.label,{color:u.labelColor,fontFamily:h.medium}],children:s}),jsxs(TouchableOpacity,{style:[Qe.selectButton,T,(!f||x.length===0)&&Qe.disabled],onPress:()=>!a&&f&&x.length>0&&y(true),activeOpacity:.7,disabled:a||!f||x.length===0,children:[_?jsxs(View,{style:Qe.selectedItem,children:[jsx(Image,{source:{uri:Z(ge(_,"png"))},style:Qe.icon}),jsx(Text,{style:[Qe.selectedText,{color:u.titleColor,fontFamily:h.medium}],numberOfLines:1,children:_.chain_name})]}):jsx(Text,{style:[Qe.placeholder,{color:u.subtitleColor,fontFamily:h.regular}],children:"Chain"}),jsx(Pt,{size:16,color:u.actionColor,strokeWidth:2})]})]}),jsxs(ct,{visible:w,onClose:()=>c(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:l,borderTopRightRadius:m,children:[jsxs(View,{style:Qe.pickerHeader,children:[jsx(View,{style:Qe.pickerHeaderSpacer}),jsx(Text,{style:[Qe.pickerTitle,{color:k.foreground,fontFamily:h.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:Qe.pickerHeaderClose,onPress:()=>c(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:k.foregroundMuted,strokeWidth:2})})]}),jsx(BottomSheetFlatList,{data:e,keyExtractor:C=>C.symbol,contentContainerStyle:Qe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:C})=>jsxs(TouchableOpacity,{style:[Qe.pickerItem,{backgroundColor:C.symbol===t?k.cardHover:"transparent"}],onPress:()=>{o(C.symbol),c(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:Z(ge(C,"png"))},style:Qe.pickerIcon}),jsx(Text,{style:[Qe.pickerItemText,{color:k.foreground,fontFamily:h.medium}],children:C.symbol}),jsx(Text,{style:[Qe.pickerItemSub,{color:k.foregroundMuted,fontFamily:h.regular}],children:C.name}),C.symbol===t&&jsx(qe,{size:18,color:k.primary,strokeWidth:2.5})]})})]}),jsxs(ct,{visible:S,onClose:()=>y(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:d,borderTopRightRadius:g,children:[jsxs(View,{style:Qe.pickerHeader,children:[jsx(View,{style:Qe.pickerHeaderSpacer}),jsx(Text,{style:[Qe.pickerTitle,{color:k.foreground,fontFamily:h.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:Qe.pickerHeaderClose,onPress:()=>y(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:k.foregroundMuted,strokeWidth:2})})]}),jsx(BottomSheetFlatList,{data:x,keyExtractor:C=>Od(C.chain_id,C.chain_type),contentContainerStyle:Qe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:C})=>{let R=Od(C.chain_id,C.chain_type);return jsxs(TouchableOpacity,{style:[Qe.pickerItem,{backgroundColor:R===r?k.cardHover:"transparent"}],onPress:()=>{n(R),y(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:Z(ge(C,"png"))},style:Qe.pickerIcon}),jsx(Text,{style:[Qe.pickerItemText,{color:k.foreground,fontFamily:h.medium}],children:C.chain_name}),R===r&&jsx(qe,{size:18,color:k.primary,strokeWidth:2.5})]})}})]})]})}var Qe=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 Dd(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 Yo({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,s,a],queryFn:()=>oc({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 cy(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function dy(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 uy(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function Fl({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:l,selectedChain:m,balanceData:d,isLoadingBalance:g,minimumWithdrawAmountUsd:k,estimatedProcessingTime:h,maxSlippagePercent:b,priceImpactPercent:w,canWithdraw:c,onDepositWalletCreation:S,onWithdraw:y,onWithdrawError:u,onWithdrawSubmitted:f,onViewTracker:x}){let _="https://unifold.io/terms",T="https://unifold.io/support",{colors:C,fonts:R,components:B}=V(),[E,D]=useState(s||""),[P,q]=useState(""),[j,fe]=useState(false),[Ke,De]=useState(null),[G,Se]=useState(false),[he,Ie]=useState(""),Ge=useRef(null);useEffect(()=>{D(s||""),q(""),De(null);},[s]);let ke=E.trim();useEffect(()=>{let de=setTimeout(()=>Ie(ke),500);return ()=>clearTimeout(de)},[ke]);let{data:Y,isLoading:Te,error:st}=Dd({chainType:m?.chain_type,chainId:m?.chain_id,tokenAddress:m?.token_address,recipientAddress:he,publishableKey:e,enabled:he.length>5&&!!m}),We=ke!==he,Ye=useMemo(()=>!ke||ke.length<=5||We||Te?null:st?"Invalid address":Y&&!Y.valid?Y.failure_code==="account_not_found"?`Account not found on ${m?.chain_name}`:Y.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${l?.symbol} on ${m?.chain_name}`:"Invalid address":null,[ke,We,Te,st,Y,m,l]),Ae=!We&&!!Y?.valid&&!Ye,Ee=useMemo(()=>d?.exchangeRate?parseFloat(d.exchangeRate):0,[d]),Me=useMemo(()=>d?.balanceHuman?parseFloat(d.balanceHuman):0,[d]),pe=n||d?.symbol||"TOKEN",ee=d?.decimals??6,be=useMemo(()=>{let de=parseFloat(P);return !de||de<=0?0:de},[P]),pt=useMemo(()=>{let de=parseFloat(P);return !de||de<=0?0:de*Ee},[P,Ee]),M=useCallback(async()=>{try{let et=await Em("expo-clipboard").getStringAsync();et&&(D(et.trim()),De(null));}catch{}},[]),W=useCallback(()=>{Me<=0||q(d?.balanceHuman??"0");},[Me,d]),se=k!==null&&pt>0&&pt<k,oe=be>0&&Me>0&&be>Me,ve=ke.length>0&&P.trim().length>0&&be>0&&Ae&&!se&&!oe&&!!d,xt=useCallback(async()=>{if(!(!l||!m||!ve||!c)){fe(true),De(null);try{let de=await S({destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,recipientAddress:ke}),et=dy(be,ee),xr=uy(be,ee),_t={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:pe,sourceTokenIconUrl:i,destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,destinationTokenSymbol:l.symbol,destinationChainName:m.chain_name,destinationTokenIconUrl:l?Z(ge(l,"png")):void 0,amount:xr,amountBaseUnit:et,submittedAt:new Date,withdrawIntentAddress:de.address,recipientAddress:ke};await y(_t),f(_t);}catch(de){let et=de instanceof Error?de.message:"Withdrawal failed. Please try again.",xr=et.length>120?"Withdrawal failed. Please try again.":et;De(xr),u?.({message:et,error:de,code:"WITHDRAW_FAILED"});}finally{fe(false);}}},[l,m,ve,c,ke,t,r,o,pe,i,P,Me,d,be,ee,pt,S,y,u,f]),ce=B.input,ae=B.card,ze=B.button,Yt=Ye?C.error:ce.borderColor,mt=useMemo(()=>j?"Processing...":oe?"Insufficient balance":se?`Minimum $${k?.toFixed(2)}`:Ke?"Withdrawal failed \u2014 try again":"Withdraw",[j,oe,se,k,Ke]);return jsxs(View,{style:$e.container,children:[jsxs(View,{children:[jsxs(View,{style:$e.labelRow,children:[jsx(Text,{style:[$e.label,{color:ae.labelColor,fontFamily:R.medium}],children:"Recipient address"}),(We||Te)&&ke.length>5?jsx(ActivityIndicator,{size:"small",color:C.foregroundMuted}):jsx(TouchableOpacity,{onPress:M,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx(jd,{size:16,color:C.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[$e.inputRow,{backgroundColor:ce.backgroundColor,borderRadius:ce.borderRadius,borderWidth:ce.borderWidth,borderColor:Yt}],children:jsx(TextInput,{style:[$e.textInput,{color:ce.textColor,fontFamily:R.regular}],placeholder:"Enter wallet address",placeholderTextColor:ce.placeholderColor,value:E,onChangeText:de=>{D(de),De(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>Ge.current?.focus()})}),Ye?jsx(Text,{style:[$e.errorText,{color:C.error,fontFamily:R.regular}],children:Ye}):null]}),jsxs(View,{children:[jsxs(Text,{style:[$e.label,{color:ae.labelColor,fontFamily:R.medium,paddingBottom:8}],children:["Amount",k!=null&&k>0&&jsx(Text,{style:{color:C.warning,fontFamily:R.regular},children:` ($${k.toFixed(2)} min)`})]}),jsxs(View,{style:[$e.amountRow,{backgroundColor:ce.backgroundColor,borderRadius:ce.borderRadius,borderWidth:ce.borderWidth,borderColor:ce.borderColor}],children:[jsx(TextInput,{ref:Ge,style:[$e.amountInput,{color:ce.textColor,fontFamily:R.regular}],placeholder:"0.00",placeholderTextColor:ce.placeholderColor,value:P,onChangeText:de=>{(de===""||/^\d*\.?\d*$/.test(de))&&(q(de),De(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(Text,{style:[$e.unitLabel,{color:C.foregroundMuted,fontFamily:R.medium}],children:pe}),jsx(TouchableOpacity,{style:[$e.maxButton,{backgroundColor:`${C.primary}20`}],onPress:W,activeOpacity:.7,children:jsx(Text,{style:[$e.maxText,{color:C.primary,fontFamily:R.medium}],children:"Max"})})]})]}),jsxs(View,{style:[$e.detailsCard,{marginTop:24,backgroundColor:ae.backgroundColor,borderRadius:ae.borderRadius,borderWidth:ae.borderWidth||1,borderColor:ae.borderColor}],children:[jsx(TouchableOpacity,{style:$e.detailsToggle,onPress:()=>Se(!G),activeOpacity:.7,children:jsxs(View,{style:$e.detailsRow,children:[jsx(View,{style:[$e.detailIcon,{backgroundColor:ae.iconBackgroundColor,borderRadius:ae.iconContainerBorderRadius}],children:jsx(bo,{size:12,color:ae.iconColor,strokeWidth:2})}),jsxs(Text,{style:[$e.detailsLabel,{color:ae.titleColor,fontFamily:R.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:R.medium},children:cy(h)})]}),jsx(View,{style:{transform:[{rotate:G?"180deg":"0deg"}]},children:jsx(Pt,{size:16,color:ae.actionColor,strokeWidth:2})})]})}),G&&jsxs(View,{style:$e.detailsExpanded,children:[jsxs(View,{style:$e.detailsRow,children:[jsx(View,{style:[$e.detailIcon,{backgroundColor:ae.iconBackgroundColor,borderRadius:ae.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:ae.iconColor,strokeWidth:2})}),jsxs(Text,{style:[$e.detailsLabel,{color:ae.titleColor,fontFamily:R.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:R.medium},children:["Auto \u2022 ",(b??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:$e.detailsRow,children:[jsx(View,{style:[$e.detailIcon,{backgroundColor:ae.iconBackgroundColor,borderRadius:ae.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:ae.iconColor,strokeWidth:2})}),jsxs(Text,{style:[$e.detailsLabel,{color:ae.titleColor,fontFamily:R.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:R.medium},children:[(w??0).toFixed(2),"%"]})]})]})]})]}),Ke&&jsx(Text,{style:[$e.errorText,{color:C.error,fontFamily:R.regular,textAlign:"center"}],children:Ke}),jsxs(View,{style:$e.withdrawRow,children:[jsxs(TouchableOpacity,{style:[$e.withdrawButton,{backgroundColor:ze.primaryBackground,borderRadius:ze.borderRadius,borderWidth:ze.borderWidth,borderColor:ze.borderColor,opacity:!ve||!c||j?.5:1}],onPress:xt,disabled:!ve||!c||j,activeOpacity:.8,children:[j&&jsx(ActivityIndicator,{size:"small",color:ze.primaryText}),jsx(Text,{style:[$e.withdrawButtonText,{color:ze.primaryText,fontFamily:R.medium}],children:mt})]}),jsxs(View,{style:$e.footerRow,children:[jsxs(TouchableOpacity,{style:$e.historyLink,onPress:x,activeOpacity:.7,children:[jsx(bo,{size:14,color:C.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[$e.historyText,{color:C.foregroundMuted,fontFamily:R.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:$e.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(_),activeOpacity:.7,children:jsx(Text,{style:[$e.legalText,{color:C.foregroundMuted,fontFamily:R.regular}],children:"Terms"})}),jsx(Text,{style:[$e.legalSeparator,{color:C.foregroundMuted,fontFamily:R.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(T),activeOpacity:.7,children:jsx(Text,{style:[$e.legalText,{color:C.foregroundMuted,fontFamily:R.regular}],children:"Help"})})]})]})]})]})}var $e=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 fy(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 hy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Bl({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=V(),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=Z(ge(e.destination_token_metadata,"png")||Ht("/icons/tokens/png/usdc.png")),d=s?"Withdrawal Failed":i?"Withdrawal Processing":"Withdrawal Completed",g=fy(e.created_at||new Date().toISOString()),k=hy(e.source_amount_usd);return jsxs(Gt,{cardTokens:a,onPress:t,contentStyle:ln.container,children:[jsxs(View,{style:ln.iconContainer,children:[jsx(Image,{source:{uri:m},style:ln.tokenIcon}),jsx(View,{style:[ln.statusBadge,{backgroundColor:l,borderColor:a.backgroundColor}],children:s?jsx(Ss,{size:12,color:"#FFFFFF",strokeWidth:2.5}):i?jsx(ha,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(qe,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:ln.textContainer,children:[jsx(Text,{style:[ln.title,{color:a.titleColor,fontFamily:o.medium}],children:d}),jsx(Text,{style:[ln.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:g})]}),jsxs(View,{style:ln.rightContainer,children:[jsx(Text,{style:[ln.amount,{color:a.textRightColor,fontFamily:o.medium}],children:k}),jsx(Vr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var ln=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 Ld(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 _m(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 yy(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 Rm(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function Im(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function la({label:e,value:t,isLast:r}){let{fonts:o,components:n}=V(),a=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:Be.detailRow,children:[jsx(Text,{style:[Be.detailLabel,{color:a.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[Be.detailValue,{color:a.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[Be.divider,{backgroundColor:a.borderColor}]})]})}function Wd({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:a}){let{colors:i,fonts:s,components:l}=V(),[m,d]=useState([]),[g,k]=useState(!!n),h=l.card,b=l.button,w=l.header,c=l.container;useEffect(()=>{rc().then(fe=>d(fe.data)).catch(()=>{});},[]),useEffect(()=>{k(!!n);},[e?.id]);let S=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,y=e?e.status==="failed"||e.status==="refunded":false,u=y?i.error:S?i.warning:i.success,f=y?"Failed":S?"Processing":"Completed",x=e?.destination_token_metadata?Z(ge(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?Z(t.destinationTokenIconUrl):Z(Ht("/icons/tokens/png/usdc.png")),_=e?.created_at?Ld(e.created_at):t.submittedAt?Ld(t.submittedAt.toISOString()):Ld(new Date().toISOString()),T=e?`${_m(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${Rm(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,C=e?`${_m(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${Rm(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,R=e?yy(e.source_amount_usd,e.source_amount_base_unit):"$0.00",B=e?ka(m,e.source_chain_type,e.source_chain_id):t.sourceChainId,E=e?ka(m,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,D=e?.transaction_hash,P=e?.explorer_url,q=e?.destination_transaction_hashes?.[0],j=e?.destination_explorer_url;return jsxs(BottomSheetScrollView,{style:Be.scroll,contentContainerStyle:Be.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Be.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ri,{size:22,color:w.buttonColor,strokeWidth:2})}):jsx(View,{style:Be.headerSpacer}),jsx(Text,{style:[Be.headerTitle,{color:w.titleColor,fontFamily:s.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:Be.headerSpacer}):jsx(TouchableOpacity,{onPress:a??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:w.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:Be.iconContainer,children:[jsx(Image,{source:{uri:x},style:Be.tokenIcon}),jsx(View,{style:[Be.statusBadge,{backgroundColor:u}],children:y?jsx(Ss,{size:10,color:"#FFFFFF",strokeWidth:3}):S?jsx(View,{style:Be.spinnerDot}):jsx(qe,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Be.statusRow,children:[jsx(View,{style:[Be.statusDot,{backgroundColor:u}]}),jsx(Text,{style:[Be.statusText,{color:u,fontFamily:s.medium}],children:f})]}),jsx(Text,{style:[Be.dateText,{color:c.subtitleColor,fontFamily:s.regular}],children:_}),jsxs(View,{style:[Be.detailsCard,{backgroundColor:h.backgroundColor,borderRadius:h.borderRadius,borderWidth:h.borderWidth??1,borderColor:h.borderColor}],children:[jsx(la,{label:"Amount Sent",value:T}),jsx(la,{label:"Amount Received",value:C}),jsx(la,{label:"USD Value",value:R}),jsx(la,{label:"Source Network",value:B}),jsx(la,{label:"Destination Network",value:E,isLast:true})]}),jsxs(TouchableOpacity,{style:Be.moreDetailsRow,onPress:()=>k(fe=>!fe),activeOpacity:.7,children:[jsx(Text,{style:[Be.moreDetailsText,{color:c.actionTitle,fontFamily:s.regular}],children:g?"See less":n?"See more":"See more details"}),g?jsx(wo,{size:16,color:c.actionColor,strokeWidth:2}):jsx(Pt,{size:16,color:c.actionColor,strokeWidth:2})]}),g&&jsx(View,{style:[Be.detailsCard,{backgroundColor:h.backgroundColor,borderRadius:h.borderRadius,borderWidth:h.borderWidth??1,borderColor:h.borderColor}],children:D&&P?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:Be.txRow,onPress:()=>Linking.openURL(P),activeOpacity:.7,children:[jsx(Text,{style:[Be.txLabel,{color:h.subtitleColor,fontFamily:s.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[Be.txHash,{color:h.titleColor,fontFamily:s.regular}],children:Im(D)}),jsx(Co,{size:14,color:h.actionColor,strokeWidth:2})]}),!S&&q&&j&&jsxs(Fragment,{children:[jsx(View,{style:[Be.divider,{backgroundColor:h.borderColor}]}),jsxs(TouchableOpacity,{style:Be.txRow,onPress:()=>Linking.openURL(j),activeOpacity:.7,children:[jsx(Text,{style:[Be.txLabel,{color:h.subtitleColor,fontFamily:s.regular}],children:"Completion Tx"}),jsx(Text,{style:[Be.txHash,{color:h.titleColor,fontFamily:s.regular}],children:Im(q)}),jsx(Co,{size:14,color:h.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:Be.detailRow,children:jsx(Text,{style:[Be.detailLabel,{color:h.subtitleColor,fontFamily:s.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:Be.buttonRow,children:[jsx(TouchableOpacity,{style:[Be.button,Be.halfButton,{backgroundColor:b.secondaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Be.buttonText,{color:b.secondaryText,fontFamily:s.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[Be.button,Be.halfButton,{backgroundColor:b.primaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Be.buttonText,{color:b.primaryText,fontFamily:s.medium}],children:"Close"})})]})]})}var Be=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 vm(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Wl({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:a,components:i}=V(),s=t.length>0?t[t.length-1]:null,l=s?.status==="succeeded",m=s?.status==="failed",d={borderRadius:i.button.borderRadius,borderWidth:i.button.borderWidth,borderColor:i.button.borderColor};return l?jsxs(View,{style:Ct.container,children:[jsx(TouchableOpacity,{style:Ct.closeButton,onPress:r,children:jsx(tt,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Ct.iconRing,{backgroundColor:n.successBackground}],children:jsx(qe,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[Ct.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[Ct.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",vm(e.recipientAddress)]}),jsxs(View,{style:Ct.buttonRow,children:[jsx(TouchableOpacity,{style:[Ct.button,Ct.halfButton,d,{backgroundColor:i.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Ct.buttonText,{color:i.button.secondaryText,fontFamily:a.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[Ct.button,Ct.halfButton,d,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Ct.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]})]}):m?jsxs(View,{style:Ct.container,children:[jsx(TouchableOpacity,{style:Ct.closeButton,onPress:r,children:jsx(tt,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Ct.iconRing,{backgroundColor:n.errorBackground}],children:jsx(tt,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[Ct.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[Ct.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[Ct.button,Ct.fullButton,d,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Ct.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]}):jsxs(View,{style:Ct.container,children:[jsx(TouchableOpacity,{style:Ct.closeButton,onPress:r,children:jsx(tt,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(ht,{size:80,strokeWidth:4,iconSize:68,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:Z(e.sourceTokenIconUrl)},style:Ct.tokenIconFill}):jsx(View,{style:[Ct.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[Ct.title,{color:n.foreground,fontFamily:a.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[Ct.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",vm(e.recipientAddress)]})]})}var Ct=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 Ty(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:Z(ge(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:Z(ge(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 Pm=(e,t)=>`${t}:${e}`;function xy(){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 Ml({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:a,modalTitle:i="Withdraw Crypto",onWithdraw:s,onWithdrawSuccess:l,onWithdrawError:m,heightPercent:d=.94,sheetBorderRadius:g,sourceChainType:k,sourceChainId:h,sourceTokenAddress:b,sourceTokenSymbol:w,sourceChainName:c,sourceTokenIconUrl:S}){let{colors:y,fonts:u}=V(),[f,x]=useState("form"),[_,T]=useState(k),[C,R]=useState(h),[B,E]=useState(b),[D,P]=useState(w),[q,j]=useState(c),[fe,Ke]=useState(S),[De,G]=useState(null),[Se,he]=useState(null),[Ie,Ge]=useState(null),[ke,Y]=useState(),[Te,st]=useState([]),[We,Ye]=useState(null),[Ae,Ee]=useState("form"),Me=useRef(new Animated.Value(Dimensions.get("window").width)).current,pe=useRef(null),ee=!!_&&!!C&&!!B,{data:be,isLoading:pt}=Ol(r,e&&f==="form"),M=be?.data??[],{data:W,isLoading:se}=Id({sourceChainType:_,sourceChainId:C,sourceTokenAddress:B,sourceTokenSymbol:D,publishableKey:r,enabled:e&&ee&&f==="form"}),{data:oe,isLoading:ve}=vd({address:n,chainType:_,chainId:C,tokenAddress:B,publishableKey:r,enabled:e&&ee}),{executions:xt}=Pd({userId:o,publishableKey:r,depositWalletId:ke,enabled:!!ke&&e,onWithdrawSuccess:l,onWithdrawError:m});useEffect(()=>{if(!e||f!=="tracker")return;let ne=false;return No(o,r,"withdraw").then(O=>{ne||st(O.data);}).catch(console.error),()=>{ne=true;}},[e,f,o,r]),useEffect(()=>{e&&(pe.current&&(clearTimeout(pe.current),pe.current=null),x("form"),T(k),R(h),E(b),P(w),j(c),Ke(S),G(null),he(null),Ge(null),Y(void 0),st([]),Ye(null),Ee("form"),Me.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{pe.current&&clearTimeout(pe.current);},[]),useEffect(()=>{fe||W?.iconUrl&&Ke(W.iconUrl);},[W?.iconUrl,fe]),useEffect(()=>{q||W?.chainName&&j(W.chainName);},[W?.chainName,q]),useEffect(()=>{f==="confirming"&&xt.length>0&&x("details");},[f,xt]);let ce=useCallback(()=>{t(),pe.current=setTimeout(()=>{x("form"),T(k),R(h),E(b),P(w),j(c),Ke(S),G(null),he(null),Ge(null),Y(void 0),st([]),Ye(null),Ee("form"),pe.current=null;},300);},[t,k,h,b,w,c,S]),ae=useCallback(ne=>{let O=M.find(ft=>ft.symbol===ne);O&&(G(O),O.chains.length>0&&he(O.chains[0]));},[M]),ze=useCallback(ne=>{if(!De)return;let O=De.chains.find(ft=>Pm(ft.chain_id,ft.chain_type)===ne);O&&he(O);},[De]),Yt=useCallback(async ne=>{let O=await Uo({external_user_id:o,destination_chain_type:ne.destinationChainType,destination_chain_id:ne.destinationChainId,destination_token_address:ne.destinationTokenAddress,recipient_address:ne.recipientAddress,action_type:"withdraw"},r),ft=Ho(O.data,_??"");if(!ft)throw new Error(`No deposit wallet found for chain type: ${_}`);return Y(ft.id),{id:ft.id,address:ft.address}},[o,r,_]),mt=useCallback(ne=>{Ge(ne),x("confirming");},[]),de=useCallback(ne=>{Ye(ne),Me.setValue(Dimensions.get("window").width),Animated.timing(Me,{toValue:0,duration:280,useNativeDriver:true}).start();},[Me]),et=useCallback(()=>{Animated.timing(Me,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>Ye(null));},[Me]),xr=pt||se,_t=W?.isSupported??null,io=f==="confirming"?"Withdrawal Status":i,Or=g?.globalBorderTopLeftRadius,ir=g?.globalBorderTopRightRadius,$t=g?.main?.borderTopLeftRadius??Or,xe=g?.main?.borderTopRightRadius??ir,at=g?.tokenSelector?.borderTopLeftRadius??Or,N=g?.tokenSelector?.borderTopRightRadius??ir,re=g?.chainSelector?.borderTopLeftRadius??Or,_e=g?.chainSelector?.borderTopRightRadius??ir,ue=(()=>{if(f!=="form"||!ee||ve||!oe)return;let ne=D||oe.symbol,O=oe.balanceUsd;if(O!=null){let un=`$${parseFloat(O).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return ne?`Balance: ${un} ${ne}`:`Balance: ${un}`}let ft=oe.balanceHuman;if(!(!ft||ft==="0"))return ne?`Balance: ${ft} ${ne}`:`Balance: ${ft}`})();return jsx(ct,{visible:e,onClose:ce,closeOnBackdropPress:false,enablePanDownToClose:f==="tracker",showHandle:f==="tracker",heightPercent:f==="confirming"?.3:f==="details"?.7:f==="tracker"?.6:d,maxHeightPercent:f==="tracker"?.9:void 0,borderTopLeftRadius:$t,borderTopRightRadius:xe,children:f==="confirming"&&Ie?jsx(Wl,{txInfo:Ie,executions:xt,onClose:ce,onViewTracker:()=>{Ee("confirming"),x("tracker");}}):f==="details"&&Ie?jsx(Wd,{execution:xt.length>0?xt[xt.length-1]:null,txInfo:Ie,onClose:ce,onViewHistory:()=>{Ee("details"),x("tracker");},onHeaderClose:()=>x("form")}):f==="tracker"?jsxs(View,{style:Ao.trackerContainer,children:[jsx(kr,{title:"Withdrawal History",onClose:()=>x(Ae)}),Te.length===0?jsx(View,{style:Ao.emptyState,children:jsx(Text,{style:[Ao.emptyText,{color:y.foregroundMuted,fontFamily:u.regular}],children:"No withdrawals to track yet"})}):jsx(BottomSheetFlatList,{data:Te,keyExtractor:ne=>ne.id,contentContainerStyle:Ao.listContent,showsVerticalScrollIndicator:false,renderItem:({item:ne})=>jsx(Bl,{execution:ne,onPress:()=>de(ne)})}),We&&jsx(Animated.View,{style:[Ao.historyDetailOverlay,{backgroundColor:y.background,transform:[{translateX:Me}]}],children:jsx(Wd,{execution:We,txInfo:Ty(We),onClose:ce,onBack:et,onViewHistory:et})})]}):jsxs(Fragment,{children:[jsx(kr,{title:io,subtitle:ue,onClose:ce}),xr?jsx(xy,{}):_t===false?jsxs(View,{style:Ao.unsupportedContainer,children:[jsx(Text,{style:[Ao.unsupportedTitle,{color:y.foreground,fontFamily:u.medium}],children:"Unsupported Token"}),jsx(Text,{style:[Ao.unsupportedMessage,{color:y.foregroundMuted,fontFamily:u.regular}],children:W?.errorMessage})]}):jsx(_y,{publishableKey:r,sourceChainType:_??"",sourceChainId:C??"",sourceTokenAddress:B??"",sourceTokenSymbol:D,sourceChainName:q,sourceTokenIconUrl:fe,recipientAddressProp:a,destinationTokens:M,selectedToken:De,selectedChain:Se,selectedChainKey:Se?Pm(Se.chain_id,Se.chain_type):null,onTokenChange:ae,onChainChange:ze,tokensLoading:pt,balanceData:oe??null,isLoadingBalance:ve,sourceValidation:W??null,onDepositWalletCreation:Yt,onWithdraw:s,onWithdrawError:m,onWithdrawSubmitted:mt,onViewTracker:()=>{Ee("form"),x("tracker");},tokenSelectorLeft:at,tokenSelectorRight:N,chainSelectorLeft:re,chainSelectorRight:_e})]})})}function _y({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,destinationTokens:l,selectedToken:m,selectedChain:d,selectedChainKey:g,onTokenChange:k,onChainChange:h,tokensLoading:b,balanceData:w,isLoadingBalance:c,sourceValidation:S,onDepositWalletCreation:y,onWithdraw:u,onWithdrawError:f,onWithdrawSubmitted:x,onViewTracker:_,tokenSelectorLeft:T,tokenSelectorRight:C,chainSelectorLeft:R,chainSelectorRight:B}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(BottomSheetScrollView,{style:{flex:1,paddingTop:16},contentContainerStyle:Ao.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:Ao.doubleInputWrapper,children:jsx(aa,{tokens:l,selectedTokenSymbol:m?.symbol??null,selectedChainKey:g,onTokenChange:k,onChainChange:h,isLoading:b,tokenPickerBorderTopLeftRadius:T,tokenPickerBorderTopRightRadius:C,chainPickerBorderTopLeftRadius:R,chainPickerBorderTopRightRadius:B})}),jsx(Fl,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:m,selectedChain:d,balanceData:w,isLoadingBalance:c,minimumWithdrawAmountUsd:S?.minimumAmountUsd??null,estimatedProcessingTime:S?.estimatedProcessingTime??null,maxSlippagePercent:S?.maxSlippagePercent??null,priceImpactPercent:S?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:y,onWithdraw:u,onWithdrawError:f,onWithdrawSubmitted:x,onViewTracker:_})]})})}var Ao=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 Fm=createContext(null);function By({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new Hc({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,a]=useState(false),[i,s]=useState(null),[l,m]=useState(false),[d,g]=useState(null),k=useColorScheme(),h=useRef(false);h.current||(ba({publishableKey:t}),h.current=true);let b=useMemo(()=>{let P=r?.appearance||"dark";return P==="auto"?k==="dark"?"dark":"light":P},[r?.appearance,k]);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.'),ba({publishableKey:t});},[t]),useEffect(()=>()=>{c.current&&clearTimeout(c.current),_.current&&clearTimeout(_.current);},[]);let w=useRef(null),c=useRef(null),S=useCallback(P=>{c.current&&(clearTimeout(c.current),c.current=null),w.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),w.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),w.current=null);let q=new Promise((j,fe)=>{w.current={resolve:j,reject:fe};});return s(P),a(true),q},[]),y=useCallback(()=>{w.current&&(w.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),w.current=null),a(false),c.current=setTimeout(()=>{s(null),c.current=null;},200);},[]),u=useCallback(P=>{i?.onSuccess&&i.onSuccess(P),w.current&&(w.current.resolve(P),w.current=null);},[i]),f=useCallback(P=>{console.error("[UnifoldProvider] Deposit error:",P),i?.onError&&i.onError(P),w.current&&(w.current.reject(P),w.current=null);},[i]),x=useRef(null),_=useRef(null),T=useRef(void 0),C=useCallback(P=>{_.current&&(clearTimeout(_.current),_.current=null),x.current&&(console.warn("[UnifoldProvider] A withdrawal is already in progress. Cancelling previous withdrawal."),x.current.reject({message:"Withdrawal cancelled - new withdrawal started",code:"WITHDRAW_SUPERSEDED"}),x.current=null);let q=new Promise((j,fe)=>{x.current={resolve:j,reject:fe};});return T.current=P.onClose,g(P),m(true),q},[]),R=useCallback(()=>{x.current&&(x.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),x.current=null),T.current?.(),T.current=void 0,m(false),_.current=setTimeout(()=>{g(null),_.current=null;},200);},[]),B=useCallback(P=>{d?.onSuccess&&d.onSuccess(P),x.current&&(x.current.resolve(P),x.current=null);},[d]),E=useCallback(P=>{console.error("[UnifoldProvider] Withdraw error:",P),d?.onError&&d.onError(P),x.current&&(x.current.reject(P),x.current=null);},[d]),D=useMemo(()=>({publishableKey:t,beginDeposit:S,closeDeposit:y,beginWithdraw:C,closeWithdraw:R}),[t,S,y,C,R]);return jsx($c,{client:o,children:jsx(Fm.Provider,{value:D,children:jsxs(vi,{mode:b,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,i&&jsx(Pl,{visible:n,onClose:y,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?Nu():void 0,onDepositSuccess:u,onDepositError:f,theme:b,sheetBorderRadius:r?.sheetBorderRadius}),d&&jsx(Ml,{visible:l,onClose:R,publishableKey:t,externalUserId:d.externalUserId,senderAddress:d.senderAddress,recipientAddress:d.recipientAddress,sourceChainType:d.sourceChainType,sourceChainId:d.sourceChainId,sourceTokenAddress:d.sourceTokenAddress,sourceTokenSymbol:d.sourceTokenSymbol,onWithdraw:d.withdraw,onWithdrawSuccess:B,onWithdrawError:E,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function Wy(){let e=useContext(Fm);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
- export{Da as AmountScreen,ct as BottomSheet,Fa as KYCWizardScreen,Ha as OnrampScreen,Na as StripeOnramp,Uu as StripeOnrampPreconfigure,By as UnifoldProvider,ge as getPreferredIcon,Ba as getStripePublishableKey,Ta as getSupportedDestinationTokens,Z as normalizeIconUrl,ja as registerStripeOnramp,Kd as setDevApiUrl,La as setStripeOnrampApiUrl,Va as setStripeOnrampPublishableKey,na as useAllowedCountry,Aa as useStripeOnramp,V as useTheme,Wy as useUnifold};
1
+ import*as Fn from'react';import {createContext,useContext,useRef,useState,useMemo,useEffect,useCallback,useId,Fragment as Fragment$1}from'react';import {StyleSheet,Platform,Modal,StatusBar,View,TouchableOpacity,Text,ActivityIndicator,KeyboardAvoidingView,TextInput,Keyboard,useColorScheme,Animated,Easing,Dimensions,Image,Linking,Clipboard,ScrollView}from'react-native';import Bt,{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 sf,{BottomSheetBackdrop,BottomSheetView,BottomSheetScrollView,BottomSheetFlatList}from'@gorhom/bottom-sheet';import {GestureHandlerRootView,TouchableOpacity as TouchableOpacity$1}from'react-native-gesture-handler';import {Onramp,useOnramp,isPlatformPaySupported,PlatformPay,initStripe}from'@stripe/stripe-react-native';import Tc from'@react-native-async-storage/async-storage';import kh from'expo-constants';import og from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var Ud=e=>{throw TypeError(e)};var Mm=(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 Ul=(e,t,r)=>t.has(e)||Ud("Cannot "+r);var p=(e,t,r)=>(Ul(e,t,"read from private field"),r?r.call(e):t.get(e)),Y=(e,t,r)=>t.has(e)?Ud("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),B=(e,t,r,o)=>(Ul(e,t,"write to private field"),t.set(e,r),r),Le=(e,t,r)=>(Ul(e,t,"access private method"),r);var bs=(e,t,r,o)=>({set _(n){B(e,t,n);},get _(){return p(e,t,o)}});var Hl={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)"}},Nl=Hl;function pa(e,t){return t?{...e,...t,shadowOffset:t.shadowOffset??e.shadowOffset,backShadowOffset:t.backShadowOffset??e.backShadowOffset}:e}function Cs(e,t,r){let o=r?t?.[r]:void 0,n=(u,h,S)=>{let g=o?.[u]?.[h];if(g!==void 0)return g;let b=t?.[u]?.[h];return b!==void 0?b:S},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:pa(a,i)},transferCrypto:{depositAddress:{card:pa(a,s)}},depositCard:{quoteProvider:{card:pa(a,l)}},depositTracker:{executionRow:{card:pa(a,m)}}}}function jl(e,t,r){let n={...Hl[e]};return r&&(n.primary=r),t&&(n={...n,...t}),n}var $l=createContext(null);function D(){let e=useContext($l);if(!e){let t=Nl.dark;return {mode:"dark",colors:t,fonts:{regular:void 0,medium:void 0,semibold:void 0,bold:void 0},components:Cs(t,void 0,"dark"),isDark:true}}return e}function ht({size:e=56,strokeWidth:t=3,children:r,iconSize:o,style:n,gradientFrom:a,gradientTo:i}){let{colors:s}=D(),l=a??s.warning,m=i??"#FBBF24",u=useRef(new Animated.Value(0)).current,h=useId(),S=useMemo(()=>`circularProgressGrad_${h.replace(/[^a-zA-Z0-9_-]/g,"")}`,[h]),g=(e-t)/2,b=2*Math.PI*g,w=e/2,c=o??Math.max(0,Math.round(e-t*2-8)),C=(e-c)/2;useEffect(()=>{let f=Animated.loop(Animated.timing(u,{toValue:1,duration:1500,easing:Easing.linear,useNativeDriver:true}));return f.start(),()=>f.stop()},[u]);let y=u.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:y}]},children:jsxs(Bt,{width:e,height:e,children:[jsx(Defs,{children:jsxs(LinearGradient,{id:S,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[jsx(Stop,{offset:"0%",stopColor:l}),jsx(Stop,{offset:"100%",stopColor:m})]})}),jsx(Circle,{cx:w,cy:w,r:g,stroke:`url(#${S})`,strokeWidth:t,fill:"none",strokeDasharray:`${b*.75} ${b*.25}`,strokeLinecap:"round",rotation:-90,origin:`${w}, ${w}`})]})}),r!=null?jsx(View,{style:{position:"absolute",top:C+1.5,left:C,width:c,height:c},children:r}):null]})}function Kl({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 _i({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 bo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 ws({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 tt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 Vr({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 Ri({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 Pt({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 Hn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 qe({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 Ss({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 Gl({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 Co({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 mn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 fa({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 wo({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsx(Bt,{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 ha({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 Ii({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 fn({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 ga({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 ks({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 $d({size:e=24,color:t="#fff",strokeWidth:r=2}){return jsxs(Bt,{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 vi({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 g=o?.[l];return jl(l,g,r)},[l,o,r]),u=useMemo(()=>Cs(m,i,l),[m,i,l]),h=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]),S=useMemo(()=>({mode:l,colors:m,fonts:h,components:u,isDark:l==="dark"}),[l,m,h,u]);return jsx($l.Provider,{value:S,children:e})}function ct({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:u=24,borderTopRightRadius:h=24}){let{colors:S,components:g}=D(),b=useRef(null),w=i!=null&&i>=1,[c,C]=useState(false),y=useRef(false),f=useRef(e),d=useMemo(()=>{if(i!=null){let W=[`${Math.round(i*100)}%`];return s!=null&&s>i&&W.push(`${Math.round(s*100)}%`),W}},[i,s]),T=d?d.join("-"):"dynamic",_=l&&d&&d.length>1?d.length-1:0;useEffect(()=>{let W=e&&!f.current;if(f.current=e,e&&!c)if(W)y.current=false,k(_),C(true);else {let $=requestAnimationFrame(()=>{y.current=false,k(_),C(true);});return ()=>cancelAnimationFrame($)}else e&&c?y.current=false:!e&&c&&(y.current=true,b.current?b.current.close():C(false));},[e,c]);let[x,k]=useState(_),I=d!=null&&d.length>1,A=n&&(!I||x===0),V=useCallback(W=>{W>=0&&k(W),W===-1&&(C(false),y.current||t(),y.current=false);},[t]),F=useCallback(W=>jsx(BottomSheetBackdrop,{...W,disappearsOnIndex:-1,appearsOnIndex:0,opacity:.5,pressBehavior:o?"close":"none"}),[o]);if(!c)return null;let P=w||m?0:Platform.OS==="ios"?34:24;return jsx(Modal,{visible:true,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:()=>{b.current?b.current.close():t();},children:jsx(GestureHandlerRootView,{style:[xs.container,Platform.OS==="android"&&{paddingTop:StatusBar.currentHeight}],children:jsx(sf,{ref:b,index:_,snapPoints:d,enableDynamicSizing:d==null,enablePanDownToClose:A,onChange:V,backdropComponent:F,handleIndicatorStyle:a?[xs.handleIndicator,{backgroundColor:S.border}]:xs.hiddenHandle,handleStyle:a?xs.handleArea:xs.hiddenHandleArea,backgroundStyle:[{backgroundColor:S.background,borderTopLeftRadius:w?0:u,borderTopRightRadius:w?0:h},g.sheet.shadowColor?{shadowColor:g.sheet.shadowColor,shadowOffset:g.sheet.shadowOffset,shadowOpacity:g.sheet.shadowOpacity,shadowRadius:g.sheet.shadowRadius,elevation:g.sheet.elevation}:void 0],children:d?jsxs(Fragment,{children:[r,P>0&&jsx(View,{style:{height:P}})]}):jsx(BottomSheetView,{style:{paddingBottom:P},children:r})},T)})})}var xs=StyleSheet.create({container:{flex:1},handleArea:{paddingTop:12,paddingBottom:4},handleIndicator:{width:36,height:4,borderRadius:2},hiddenHandle:{height:0,opacity:0},hiddenHandleArea:{padding:0,height:0}});var pf="https://api.unifold.io",Jl="__UnifoldDevApiBaseUrl__",Cr="pk_test_123",ya={};function mf(){if(typeof __DEV__>"u"||!__DEV__||typeof globalThis>"u")return;let e=globalThis[Jl];if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function qt(){return mf()??pf}function ba(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.'),Cr=e.publishableKey;}e.defaultConfig&&(ya=e.defaultConfig);}function Gd(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[Jl]=t:delete globalThis[Jl];}function _s(){return qt()}function Ca(){return Cr}function Lr(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 Ht(e){let t=e.startsWith("/")?e:`/${e}`;return `${qt()}/api/public${t}`}function J(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,qt()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${qt()}${e}`:`${qt()}/api/public${e}`:""}async function Uo(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let r=e?.recipient_address||ya.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||ya.destinationChainId||"8453",destination_token_address:e?.destination_token_address||ya.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:r,...e?.action_type&&{action_type:e.action_type},client_metadata:e?.client_metadata||{}},n=t||Cr;Lr(n);let a=await fetch(`${qt()}/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 Ho(e,t){return e.find(r=>r.chain_type===t)}async function No(e,t,r){let o=t||Cr;Lr(o);let n=await fetch(`${qt()}/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 wa(e,t){let r=t||Cr;Lr(r);let o=await fetch(`${qt()}/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 ge(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 Nn(e,t){let r=e||Cr;Lr(r);let o=`${qt()}/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 Zl(e,t){let r=t||Cr;Lr(r);let o=new URLSearchParams({chainType:e.chain_type,chainId:e.chain_id,tokenAddress:e.token_address}),n=await fetch(`${qt()}/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 Sa(e,t,r){return !e||e.length===0?r||"":e.find(n=>n.format===t)?.url||r||e[0]?.url||""}async function Xl(e,t){let r=t||Cr;Lr(r);let o=await fetch(`${qt()}/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 ec(e,t){let r=t||Cr;Lr(r);let o=await fetch(`${qt()}/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 tc(e,t){let r=t||Cr;Lr(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(`${qt()}/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 rc(e){let t=e||Cr;Lr(t);let r=await fetch(`${qt()}/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 Fi(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 Rs(e){let t=e||Cr;Lr(t);let r=await fetch(`${qt()}/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 oc(){let e=await fetch(`${qt()}/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 ka(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 Is(){let e=await fetch(`${qt()}/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 Ta(e){let t=e||Cr;Lr(t);let r=await fetch(`${qt()}/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 nc(e,t){let r=t||Cr;Lr(r);let o=await fetch(`${qt()}/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 ic(e,t){return wa(e.deposit_wallet_id,t)}async function xa(e,t,r,o,n){let a=n||Cr;Lr(a);let i=await fetch(`${qt()}/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 Jd({size:e=28}){return jsx(Bt,{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 Xd({size:e=28}){return jsxs(Bt,{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 ru({size:e=28}){return jsxs(Bt,{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 ou({size:e=28}){return jsxs(Bt,{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 nu({size:e=28}){return jsx(Bt,{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 _a=[{label:"Base",value:Onramp.CryptoNetwork.base,defaultCrypto:"usdc",Icon:Jd},{label:"Ethereum",value:Onramp.CryptoNetwork.ethereum,defaultCrypto:"eth",Icon:Xd},{label:"Bitcoin",value:Onramp.CryptoNetwork.bitcoin,defaultCrypto:"btc",Icon:ru},{label:"Solana",value:Onramp.CryptoNetwork.solana,defaultCrypto:"sol",Icon:ou},{label:"Polygon",value:Onramp.CryptoNetwork.polygon,defaultCrypto:"matic",Icon:nu}];function iu(e,t=8,r=4){let o=e.trim();return o.length<=t+r+3?o:`${o.slice(0,t)}...${o.slice(-r)}`}function Ra(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 Ia(e){let t=e.trim().toLowerCase();if(!t)return e.trim();let r=_a.find(n=>n.label.toLowerCase()===t);if(r)return r.label;let o=_a.find(n=>String(n.value).toLowerCase()===t);return o?o.label:e.trim()}function Jt({onPress:e,title:t,variant:r="close"}){let{components:o,fonts:n}=D(),a=r==="back",i=a?jsx(Ri,{size:22,color:o.header.buttonColor,strokeWidth:2.5}):jsx(tt,{size:20,color:o.header.buttonColor,strokeWidth:2}),s=jsx(TouchableOpacity,{style:hn.closeBtn,onPress:e,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:a?"Back":"Close",children:i});return t?jsxs(View,{style:hn.headerWithTitle,children:[a?s:jsx(View,{style:hn.headerSide}),jsx(Text,{style:[hn.headerTitleText,{color:o.header.titleColor},...n.bold?[{fontFamily:n.bold}]:[]],numberOfLines:1,ellipsizeMode:"tail",accessibilityRole:"header",children:t}),a?jsx(View,{style:hn.headerSide}):s]}):jsxs(View,{style:a?hn.headerWithTitle:hn.header,children:[a?s:jsx(View,{style:hn.headerSpacer}),!a&&s]})}var va={paddingTop:8,paddingBottom:8},hn=StyleSheet.create({header:{flexDirection:"row",justifyContent:"flex-end",...va},headerWithTitle:{flexDirection:"row",alignItems:"center",...va},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 wr({error:e,progress:t,loading:r}){let{colors:o,fonts:n}=D();return e?jsx(Text,{style:[su.errorText,{color:o.error},...n.regular?[{fontFamily:n.regular}]:[]],children:e.message}):t&&r&&__DEV__?jsx(Text,{style:[su.progressText,{color:o.foregroundSubtle},...n.regular?[{fontFamily:n.regular}]:[]],children:t}):null}var su=StyleSheet.create({errorText:{fontSize:14,textAlign:"center",lineHeight:20,marginTop:24},progressText:{fontSize:13,textAlign:"center",lineHeight:18,marginTop:24}});function co({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 uc({quote:e,label:t,address:r,last:o,hideDivider:n}){let[a,i]=useState(false),{colors:s,components:l}=D(),m=()=>{Clipboard.setString(r),i(true),setTimeout(()=>i(false),2e3);},u=iu(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:u}),jsx(TouchableOpacity,{onPress:m,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:`Copy ${t}`,children:a?jsx(qe,{size:14,color:s.success,strokeWidth:2.5}):jsx(Hn,{size:14,color:l.card.actionIcon,strokeWidth:2})})]})]}),!o&&!n?jsx(View,{style:e.rowDivider}):null]})}var Pa={usdc:"#2775CA",usdt:"#26A17B",eth:"#627EEA",btc:"#F7931A",sol:"#9945FF",matic:"#8247E5",dai:"#F5AC37"};function cu({currency:e,tokenIconUrl:t,networkIconUrl:r,size:o=48}){let{colors:n}=D(),a=e.toLowerCase(),i=Pa[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 Oa({sourceCurrency:e,destinationCurrency:t,destinationNetwork:r,tokenIconUrl:o,networkIconUrl:n,style:a}){let{colors:i,components:s,fonts:l}=D(),m=Ht(`/icons/currencies/png/${e.toLowerCase()}.png`),u=Ia(r);return jsxs(View,{style:[Gr.diagram,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor},a],children:[jsxs(View,{style:Gr.step,children:[jsx(Image,{source:{uri:m},style:Gr.iconImage}),jsx(Text,{style:[Gr.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You paid"}),jsx(Text,{style:[Gr.value,{color:s.card.titleColor,fontFamily:l.medium}],children:e.toUpperCase()})]}),jsx(Vr,{size:16,color:i.foregroundMuted,strokeWidth:2}),jsxs(View,{style:Gr.step,children:[jsxs(View,{style:Gr.iconWithBadge,children:[o?jsx(Image,{source:{uri:o},style:Gr.tokenIcon}):jsx(View,{style:[Gr.tokenIcon,{backgroundColor:Pa[t.toLowerCase()]??i.primary}]}),n?jsx(Image,{source:{uri:n},style:[Gr.networkBadge,{borderColor:i.background}]}):null]}),jsx(Text,{style:[Gr.label,{color:s.card.subtitleColor,fontFamily:l.regular}],children:"You receive"}),jsxs(Text,{style:[Gr.value,{color:s.card.titleColor,fontFamily:l.medium}],children:[t.toUpperCase()," ",u]})]})]})}var Gr=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 Li(){let{colors:e,fonts:t,components:r}=D(),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"}},u={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:20,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}:{}}},h={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}:{}}},S=Math.max(16,Math.min(l,22)),g={stackWrapper:{width:"100%",marginBottom:8,marginTop:4},swapCard:{backgroundColor:e.card,borderWidth:i.borderWidth,borderColor:e.border,paddingHorizontal:16,paddingVertical:16},swapCardTop:{borderTopLeftRadius:S,borderTopRightRadius:S,borderBottomLeftRadius:10,borderBottomRightRadius:10},swapCardBottom:{borderBottomLeftRadius:S,borderBottomRightRadius:S,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"}},w={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:h,pm:g,wallet:b,flow:w,amount:u}},[e,t,o,n,a,i,s])}function zf({size:e=24}){let t=e,r=e*(471/750);return jsxs(Bt,{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 Uf({size:e=24}){return jsx(Bt,{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 Hf({size:e=24}){return jsx(Bt,{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 mc({sublabel:e,size:t=24,fallbackColor:r="#888"}){if(!e)return jsx(_i,{size:t*.75,color:r,strokeWidth:1.75});let o=e.toLowerCase();return o.includes("visa")?jsx(zf,{size:t}):o.includes("mastercard")?jsx(Uf,{size:t}):o.includes("amex")||o.includes("american express")?jsx(Hf,{size:t}):jsx(_i,{size:t*.75,color:r,strokeWidth:1.75})}var Nf=[50,100,500],jf=[["1","2","3"],["4","5","6"],["7","8","9"],["\u232B","0","."]];function fu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function $f(e){return e.card?`${fu(e.card.brand)} ${fu(e.card.funding)} \u2022\u2022\u2022\u2022 ${e.card.last4}`:e.type}function Fa({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:u=[],onAddPaymentMethod:h,onConfirm:S,onCancel:g,sheetBorderTopLeftRadius:b,sheetBorderTopRightRadius:w}){let c=Li(),{colors:C,components:y}=D(),f=b??y.card.borderRadius,d=w??y.card.borderRadius,[T,_]=useState(e),[x,k]=useState(r?"apple_pay":u.length>0?u[0].id:null),I=useRef(false),A=z=>{I.current=true,k(z);};useEffect(()=>{I.current||r||u.length>0&&k(u[0].id);},[u,r]);let[V,F]=useState(false),[P,W]=useState("select"),[$,fe]=useState(null),Ke=useRef(false);useEffect(()=>{s&&l&&/saving/i.test(l)&&W("card");},[s,l]);let Fe=x==="apple_pay",G=1e3,Se=Fe?G:n,he=Se!=null&&Se>0,Ie=useMemo(()=>{if(o)return [];let z=Nf.map(E=>({label:`$${E}`,amount:String(E),disabled:false}));return Fe?z.push({label:`$${G}`,amount:String(G),disabled:false}):z.push({label:"MAX",amount:he?String(Se):"0",disabled:!he}),z},[o,he,Se,Fe]),Ge=z=>{if(z==="\u232B"){_(E=>E.slice(0,-1));return}if(z==="."){if(T.includes("."))return;_(E=>E===""?"0.":E+".");return}_(E=>{let se=E.indexOf(".");return se!==-1&&E.length-se>2?E:E==="0"&&z!=="."?z:E+z});},ke=T===""?"0":T,te=parseFloat(T),Te=T!==""&&!isNaN(te)&&te>0,st=r||u.length>0,We=a==="header",Ye=useMemo(()=>{let z=[];r&&z.push({id:"apple_pay",label:"Apple Pay",hint:"Pay with Apple Pay",isApplePay:true});for(let E of u)z.push({id:E.id,label:$f(E),hint:E.card?`Expires ${E.card.exp_month}/${E.card.exp_year}`:E.type,brand:E.card?.brand,isApplePay:false});return z},[r,u]),Ae=Ye.find(z=>z.id===x),Me=x!=null&&x!=="apple_pay",pe=Ae?Ae.label:Me&&$?$:Me?"Card":"Pay With",X=Ae?!Ae.isApplePay:Me,be=Ae?.brand??$??void 0,pt=st?jsx(TouchableOpacity,{style:[We?c.amount.paymentRowHeader:c.amount.paymentRow,s&&{opacity:.5}],onPress:()=>{s||(W("select"),F(true));},activeOpacity:.7,disabled:s,children:jsxs(View,{style:c.amount.paymentLeft,children:[Ae?.isApplePay?jsx(Text,{style:c.amount.applePayIcon,children:"\uF8FF"}):X?jsx(mc,{sublabel:be,size:20}):null,jsx(Text,{style:c.amount.paymentLabel,children:pe}),jsx(Pt,{size:12,color:c.amount.currencyLabel.color,strokeWidth:2.5})]})}):null;return jsxs(View,{style:c.form.screen,children:[jsx(Jt,{onPress:g,title:"Enter amount"}),We&&pt,jsxs(View,{style:c.form.content,children:[jsxs(View,{style:c.amount.amountContainer,children:[jsxs(Text,{style:[c.amount.amountText,ke==="0"&&c.amount.amountPlaceholder],adjustsFontSizeToFit:true,numberOfLines:1,children:["$",ke]}),jsx(Text,{style:c.amount.currencyLabel,children:t.toUpperCase()})]}),!We&&pt,Ie.length>0&&jsx(View,{style:c.amount.quickRow,children:Ie.map(z=>{let E=!z.disabled&&T===z.amount&&T!=="";return jsx(TouchableOpacity,{style:[c.amount.quickPill,E&&{backgroundColor:C.primary},z.disabled&&{opacity:.4}],activeOpacity:.7,disabled:z.disabled||s,onPress:()=>_(z.amount),children:jsx(Text,{style:[c.amount.quickPillText,E&&{color:C.primaryForeground}],children:z.label})},z.label)})}),jsx(View,{style:c.amount.numpad,children:jf.map((z,E)=>jsx(View,{style:c.amount.numpadRow,children:z.map(se=>jsx(TouchableOpacity,{style:[c.amount.numpadKey,s&&{opacity:.3}],onPress:()=>Ge(se),activeOpacity:.6,disabled:s,children:jsx(Text,{style:se==="\u232B"?c.amount.backspaceText:c.amount.numpadKeyText,children:se})},se))},E))}),jsx(TouchableOpacity,{style:[c.form.continueBtn,(!Te||s)&&c.form.continueBtnDisabled],onPress:()=>Te&&!s&&S(T,x),disabled:!Te||s,children:s?jsx(ActivityIndicator,{size:"small",color:C.primaryForeground}):jsx(Text,{style:[c.form.continueBtnText,!Te&&c.form.continueBtnTextDisabled],children:"Continue"})}),!V&&m?jsx(Text,{style:c.amount.inlineError,children:m}):!V&&s&&l&&__DEV__?jsx(Text,{style:c.amount.inlineStatus,children:l}):null]}),jsx(ct,{visible:V,onClose:()=>{s||(F(false),W("select"));},closeOnBackdropPress:!s,enablePanDownToClose:!s,showHandle:!s,heightPercent:.44,maxHeightPercent:.9,borderTopLeftRadius:f,borderTopRightRadius:d,children:jsx(View,{style:c.amount.sheetContent,children:P==="select"?jsxs(Fragment,{children:[jsxs(View,{style:c.amount.sheetTitleRow,children:[jsx(Text,{style:c.amount.sheetTitle,children:"Pay With"}),jsx(TouchableOpacity,{onPress:()=>F(false),activeOpacity:.7,style:c.amount.sheetCloseBtn,children:jsx(tt,{size:16,color:C.foregroundMuted,strokeWidth:2.5})})]}),jsxs(BottomSheetScrollView,{style:{flex:1},contentContainerStyle:{gap:8},showsVerticalScrollIndicator:false,children:[Ye.map(z=>{let E=x===z.id;return jsxs(TouchableOpacity,{style:[c.amount.sheetOption,E&&{borderColor:C.primary,borderWidth:2}],activeOpacity:.7,onPress:()=>{A(z.id),fe(z.isApplePay?null:z.label),F(false);},children:[jsxs(View,{style:c.amount.sheetOptionLeft,children:[jsx(View,{style:c.amount.sheetOptionIcon,children:z.isApplePay?jsx(Text,{style:c.amount.applePayIcon,children:"\uF8FF"}):jsx(mc,{sublabel:z.brand,size:24})}),jsxs(View,{style:{flex:1},children:[jsx(Text,{style:c.amount.sheetOptionLabel,children:z.label}),jsx(Text,{style:c.amount.sheetOptionHint,children:z.hint})]})]}),E&&jsx(qe,{size:18,color:C.primary,strokeWidth:2.5})]},z.id)}),jsx(TouchableOpacity,{style:c.amount.addPaymentBtn,activeOpacity:.7,onPress:async()=>{if(!Ke.current){Ke.current=true;try{let z=await h?.();z&&(A(z.token),fe(z.sublabel),F(!1));}finally{Ke.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,{onPress:()=>{s||W("select");},activeOpacity:.7,style:c.amount.sheetBackBtn,children:jsx(Ri,{size:20,color:C.foreground,strokeWidth:2})}),jsx(Text,{style:c.amount.sheetTitle,children:"Pay With"})]}),s?jsxs(View,{style:c.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:C.primary}),__DEV__?jsx(Text,{style:c.amount.sheetStatusText,children:l||"Loading Stripe Link..."}):null]}):m?jsxs(Fragment,{children:[jsx(View,{style:c.amount.sheetError,children:jsx(Text,{style:c.amount.sheetErrorText,children:m})}),jsx(TouchableOpacity,{style:c.form.continueBtn,onPress:()=>{i&&Te&&i(false,T);},children:jsx(Text,{style:c.form.continueBtnText,children:"Retry"})})]}):jsxs(View,{style:c.amount.sheetLoading,children:[jsx(ActivityIndicator,{size:"small",color:C.primary}),__DEV__?jsx(Text,{style:c.amount.sheetStatusText,children:"Opening card payment..."}):null]})]})})})]})}var Ds=4;function Da({initialData:e={},loading:t=false,onComplete:r,onCancel:o}){let n=Li(),{colors:a,fonts:i,components:s}=D(),l=s.input.placeholderColor,[m,u]=useState(1),[h,S]=useState(e.firstName??""),[g,b]=useState(e.lastName??""),[w,c]=useState(e.dobMonth??""),[C,y]=useState(e.dobDay??""),[f,d]=useState(e.dobYear??""),[T,_]=useState(e.addressLine1??""),[x,k]=useState(e.addressLine2??""),[I,A]=useState(e.city??""),[V,F]=useState(e.state??""),[P,W]=useState(e.postalCode??""),[$,fe]=useState(e.country??"US"),[Ke,Fe]=useState(e.idNumber??""),G=useRef(null),Se=useRef(null),he=useRef(null),Ie=useRef(null),Ge=useRef(null),ke=useRef(null),te=useRef(null),Te=useRef(null),st=()=>{switch(m){case 1:return h.trim().length>0&&g.trim().length>0;case 2:return w.length===2&&C.length===2&&f.length===4;case 3:return T.trim().length>0&&I.trim().length>0&&V.trim().length>0&&P.trim().length>0;case 4:return Ke.trim().length>0;default:return false}},We=()=>{st()&&(m<Ds?u(pe=>pe+1):r({firstName:h,lastName:g,idNumber:Ke,dobMonth:w,dobDay:C,dobYear:f,addressLine1:T,addressLine2:x,city:I,state:V,postalCode:P,country:$}));},Ye=()=>{m>1?u(pe=>pe-1):o();},Ae=["Enter your name","Enter your date of birth","Enter your address","Enter your SSN"],Ee=["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."],Me=[Wt.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:Wt.header,children:[jsx(View,{style:Wt.headerSide,children:jsx(TouchableOpacity,{style:Wt.iconButton,onPress:Ye,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:m>1?"Back":"Cancel",children:jsx(ws,{size:20,color:s.header.buttonColor,strokeWidth:2})})}),jsx(View,{style:Wt.headerCenter,children:jsxs(Text,{style:Me,children:[m," of ",Ds]})}),jsx(View,{style:Wt.headerSide,children:jsx(TouchableOpacity,{style:Wt.iconButton,onPress:o,hitSlop:{top:10,bottom:10,left:10,right:10},accessibilityRole:"button",accessibilityLabel:"Close",children:jsx(tt,{size:20,color:s.header.buttonColor,strokeWidth:2})})})]}),jsx(View,{style:Wt.progressTrack,children:Array.from({length:Ds}).map((pe,X)=>jsx(View,{style:[Wt.progressSegment,{backgroundColor:X<m||X+1===m?a.primary:a.border}]},X))}),jsxs(BottomSheetScrollView,{style:n.form.flex,contentContainerStyle:Wt.scrollContent,keyboardShouldPersistTaps:"handled",children:[jsx(Text,{style:n.form.title,children:Ae[m-1]}),jsx(Text,{style:n.form.subtitle,children:Ee[m-1]}),m===1&&jsxs(Fragment,{children:[jsx($o,{form:n.form,label:"First name",children:jsx(TextInput,{style:n.form.input,placeholder:"Jane",placeholderTextColor:l,value:h,onChangeText:S,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>G.current?.focus()})}),jsx($o,{form:n.form,label:"Last name",children:jsx(TextInput,{ref:G,style:n.form.input,placeholder:"Doe",placeholderTextColor:l,value:g,onChangeText:b,autoCapitalize:"words",returnKeyType:"done",onSubmitEditing:We})})]}),m===2&&jsxs(View,{style:Wt.dobRow,children:[jsxs(View,{style:Wt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Wt.dobLabel],children:"Month"}),jsx(TextInput,{style:[n.form.input,Wt.dobInput],placeholder:"MM",placeholderTextColor:l,value:w,onChangeText:pe=>{let X=pe.replace(/\D/g,"").slice(0,2);c(X),X.length===2&&Se.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Wt.dobCol,children:[jsx(Text,{style:[n.form.fieldLabel,Wt.dobLabel],children:"Day"}),jsx(TextInput,{ref:Se,style:[n.form.input,Wt.dobInput],placeholder:"DD",placeholderTextColor:l,value:C,onChangeText:pe=>{let X=pe.replace(/\D/g,"").slice(0,2);y(X),X.length===2&&he.current?.focus();},keyboardType:"number-pad",maxLength:2})]}),jsxs(View,{style:Wt.dobColWide,children:[jsx(Text,{style:[n.form.fieldLabel,Wt.dobLabel],children:"Year"}),jsx(TextInput,{ref:he,style:[n.form.input,Wt.dobInput],placeholder:"YYYY",placeholderTextColor:l,value:f,onChangeText:pe=>{let X=pe.replace(/\D/g,"").slice(0,4);d(X);},keyboardType:"number-pad",maxLength:4,returnKeyType:"done",onSubmitEditing:We})]})]}),m===3&&jsxs(Fragment,{children:[jsx($o,{form:n.form,label:"Street address",children:jsx(TextInput,{style:n.form.input,placeholder:"123 Main St",placeholderTextColor:l,value:T,onChangeText:_,returnKeyType:"next",onSubmitEditing:()=>Ie.current?.focus()})}),jsx($o,{form:n.form,label:"Apt, suite, etc. (optional)",children:jsx(TextInput,{ref:Ie,style:n.form.input,placeholder:"Apt 2",placeholderTextColor:l,value:x,onChangeText:k,returnKeyType:"next",onSubmitEditing:()=>Ge.current?.focus()})}),jsx($o,{form:n.form,label:"City",children:jsx(TextInput,{ref:Ge,style:n.form.input,placeholder:"San Francisco",placeholderTextColor:l,value:I,onChangeText:A,autoCapitalize:"words",returnKeyType:"next",onSubmitEditing:()=>ke.current?.focus()})}),jsxs(View,{style:Wt.row,children:[jsx(View,{style:[n.form.flex,{marginRight:8}],children:jsx($o,{form:n.form,label:"State",children:jsx(TextInput,{ref:ke,style:n.form.input,placeholder:"NY",placeholderTextColor:l,value:V,onChangeText:pe=>F(pe.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"next",onSubmitEditing:()=>te.current?.focus()})})}),jsx(View,{style:n.form.flex,children:jsx($o,{form:n.form,label:"ZIP code",children:jsx(TextInput,{ref:te,style:n.form.input,placeholder:"11201",placeholderTextColor:l,value:P,onChangeText:W,keyboardType:"number-pad",maxLength:10,returnKeyType:"next",onSubmitEditing:()=>Te.current?.focus()})})})]}),jsx($o,{form:n.form,label:"Country",children:jsx(TextInput,{ref:Te,style:n.form.input,placeholder:"US",placeholderTextColor:l,value:$,onChangeText:pe=>fe(pe.toUpperCase().slice(0,2)),autoCapitalize:"characters",maxLength:2,returnKeyType:"done",onSubmitEditing:We})})]}),m===4&&jsxs($o,{form:n.form,label:"Social Security Number",children:[jsx(TextInput,{style:n.form.input,placeholder:"123-45-6789",placeholderTextColor:l,value:Ke,onChangeText:Fe,keyboardType:"number-pad",secureTextEntry:true,returnKeyType:"done",onSubmitEditing:We}),jsx(Text,{style:[n.form.hint,Wt.ssnHint],children:"Your SSN is transmitted securely and never stored on this device."})]})]}),jsx(View,{style:n.form.footer,children:t&&m===Ds?jsx(View,{style:[n.form.continueBtn,n.form.loaderInButton],children:jsx(ht,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[n.form.continueBtn,!st()&&n.form.continueBtnDisabled],onPress:We,disabled:!st(),children:jsx(Text,{style:[n.form.continueBtnText,!st()&&n.form.continueBtnTextDisabled],children:m===Ds?"Submit":"Continue"})})})]})})}function $o({form:e,label:t,children:r}){return jsxs(View,{style:e.fieldWrap,children:[jsx(Text,{style:e.fieldLabel,children:t}),r]})}var Wt=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 gu="",yu;function Va(e){gu=e;}function La(e){yu=e;}function Er(){let e=gu||Ca();if(!e)throw new Error("[Unifold] No publishable key configured. Set via UnifoldProvider or setStripeOnrampPublishableKey().");return e}function Mr(){return yu??_s()}async function Ba(){let e=`${Mr()}/v1/public/onramps/headless/stripe/config`,t=Er(),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 bc(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/start`,{method:"POST",headers:{"x-publishable-key":Er(),"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 bu(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/token`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({auth_intent_id:e})});if(!t.ok)throw new Error(`Failed to exchange auth intent for tokens: ${t.status}`);return t.json()}async function Cc(e){let t=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/oauth/token/refresh`,{method:"POST",headers:{"x-publishable-key":Er(),"Content-Type":"application/json"},body:JSON.stringify({refresh_token:e})}),r=await t.json().catch(()=>({}));if(!t.ok)throw new Error(r?.message??`Failed to refresh OAuth token: ${t.status}`);return r}async function Cu(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(`${Mr()}/v1/public/onramps/headless/stripe/sessions`,{method:"POST",headers:{"x-publishable-key":Er(),"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 wu(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}/confirm`,{method:"POST",headers:{"x-publishable-key":Er(),"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 Wa(e,t){let r=`${Mr()}/v1/public/onramps/headless/stripe/customers/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Er(),"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 Su(e,t){let r=`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}`,o=await fetch(r,{method:"GET",headers:{"x-publishable-key":Er(),"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 wc(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/sessions/${e}/quote/refresh`,{method:"POST",headers:{"x-publishable-key":Er(),"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 ku(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(`${Mr()}/v1/public/onramps/headless/stripe/transaction_limits?${t.toString()}`,{method:"GET",headers:{"x-publishable-key":Er(),"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 Sc(e,t){let r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/customers/${e}/payment_tokens`,{method:"GET",headers:{"x-publishable-key":Er(),"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 Tu(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(`${Mr()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":Er(),"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 kc(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 xu(e){let t=new URLSearchParams({token_address:e.token_address,chain_id:e.chain_id,chain_type:e.chain_type}),r=await fetch(`${Mr()}/v1/public/onramps/headless/stripe/default_token?${t.toString()}`,{method:"GET",headers:{accept:"application/json","x-publishable-key":Er()}});if(!r.ok)throw new Error(`Failed to fetch default onramp token: ${r.status}`);return r.json()}var xc="@unifold/stripe_oauth";async function _u(){try{let e=await Tc.getItem(xc);return e?JSON.parse(e):null}catch{return null}}async function _c(e){try{await Tc.setItem(xc,JSON.stringify(e));}catch(t){console.warn("[oauthTokens] Failed to store credentials:",t);}}async function bn(){try{await Tc.removeItem(xc);}catch(e){console.warn("[oauthTokens] Failed to clear credentials:",e);}}var Xf=5,wn=null,Ru={firstName:"",lastName:"",idNumber:"",dobDay:"",dobMonth:"",dobYear:"",addressLine1:"",addressLine2:"",city:"",state:"",postalCode:"",country:"US"};function Aa(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:u,collectPaymentMethod:h,createCryptoPaymentToken:S}=useOnramp(),[g,b]=useState(r),[w,c]=useState(!!e?.externalUserId),[C,y]=useState(false),[f,d]=useState(""),[T,_]=useState(null),[x,k]=useState(e?.email??""),[I,A]=useState(e?.phone??""),[V,F]=useState(""),[P,W]=useState("US"),[$,fe]=useState(""),[Ke,Fe]=useState(""),G=useRef(""),Se=useRef(""),he=useRef(""),[Ie,Ge]=useState(false),[ke,te]=useState(false),Te=useRef(0),st=useRef(false),We=useRef(false),Ye=useRef(false),Ae=useRef(""),Ee=useRef(e?.defaultNetwork??Onramp.CryptoNetwork.base),Me=useRef(null),[pe,X]=useState(Ru),[be,pt]=useState(e?.defaultWalletAddress??"0x102471956A026866171C44F326e1DfafB6C6e34c"),[z,E]=useState(""),[se,oe]=useState(e?.defaultNetwork??Onramp.CryptoNetwork.base),[ve,xt]=useState(e?.defaultSourceAmount??"100"),[ce,ae]=useState(e?.defaultSourceCurrency??"usd"),[ze,Yt]=useState(e?.defaultDestinationCurrency??"usdc"),[mt,de]=useState(null),[et,xr]=useState(),[_t,io]=useState(),[Or,ir]=useState(false),$t=useRef(null),xe=useRef(false),at=useRef(0),j=useRef(e?.onComplete),re=useRef(e?.onError),_e=useRef(e?.onStepChange),ue=useRef(r);useEffect(()=>{j.current=e?.onComplete;},[e?.onComplete]),useEffect(()=>{re.current=e?.onError;},[e?.onError]),useEffect(()=>{_e.current=e?.onStepChange;},[e?.onStepChange]);let ne=useRef(r);useEffect(()=>{g!==ne.current&&(_e.current?.(g,ne.current),ne.current=g),ue.current=g;},[g]),useEffect(()=>{w&&g!==r&&c(false);},[w,g,r]);let O=useCallback((R,v,H)=>{let Z={code:R,message:v,step:ue.current,stripeErrorCode:H};_(Z),d(""),re.current?.(Z);},[]),ft=useCallback(R=>{let v={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 j.current?.(v),v},[]),De=useCallback(()=>_(null),[]),un=R=>R.refresh_token??R.refresh?.refresh_token??"",Si=useCallback((R,v,H,Z,me)=>{Se.current=v,G.current=H,e?.externalUserId&&_c({accessToken:v,refreshToken:H,customerId:R,externalUserId:e.externalUserId,email:me||x,expiresAt:Date.now()+Z*1e3});},[e?.externalUserId,x]),ki=useCallback(async()=>{let R=G.current;if(!R)return console.warn("[tryRefreshAccessToken] no refresh token available"),null;try{console.log("[tryRefreshAccessToken] refreshing OAuth token...");let v=await Cc(R),H=v.access_token,Z=un(v)||R;return Fe(H),Si(he.current,H,Z,v.expires_in??3600),console.log("[tryRefreshAccessToken] token refreshed successfully"),H}catch(v){return console.error("[tryRefreshAccessToken] refresh failed:",v?.message),await bn(),wn=null,Se.current="",G.current="",he.current="",Fe(""),fe(""),null}},[Si]),yo=useCallback(async R=>{try{return await R(Se.current)}catch(v){let H=v?.message??"";if(H.includes("stripe_onramp_forbidden")||H.includes("403")){console.log("[withTokenRefresh] forbidden error, attempting token refresh...");let Z=await ki();if(!Z)throw O("authorization_error","Session expired. Please sign in again."),b("email"),v;return await R(Z)}throw v}},[ki,O]);useEffect(()=>{if(!(e?.merchantIdentifier?.trim()??"")){ir(false);return}let v=false;return isPlatformPaySupported().then(H=>{v||ir(H);}),()=>{v=true;}},[e?.merchantIdentifier]),useEffect(()=>(xe.current=false,()=>{xe.current=true,$t.current&&clearTimeout($t.current);}),[]);let Ti=useRef(false);useEffect(()=>{if(Ti.current)return;if(!e?.externalUserId){console.log("[useStripeOnramp] no externalUserId provided \u2014 clearing stored tokens, forcing login"),bn(),wn=null,c(false);return}let R=false;return (async()=>{try{let v=await _u();if(R||!v){R||c(!1);return}if(v.externalUserId!==e.externalUserId){console.log("[useStripeOnramp] user mismatch \u2014 stored:",v.externalUserId,"current:",e.externalUserId),await bn(),wn=null,R||c(!1);return}console.log("[useStripeOnramp] found stored OAuth credentials for customer:",v.customerId);let H=Date.now()>=v.expiresAt,Z=v.accessToken,me=v.refreshToken;if(H){console.log("[useStripeOnramp] stored token expired, attempting refresh...");try{let He=await Cc(v.refreshToken);if(R)return;Z=He.access_token,me=He.refresh_token??He.refresh?.refresh_token??v.refreshToken,await _c({accessToken:Z,refreshToken:me,customerId:v.customerId,externalUserId:e.externalUserId,email:v.email,expiresAt:Date.now()+(He.expires_in??3600)*1e3}),console.log("[useStripeOnramp] token refreshed successfully on mount");}catch(He){console.warn("[useStripeOnramp] refresh failed on mount, user must re-login:",He?.message),await bn(),wn=null,R||c(!1);return}}if(R)return;if(Ti.current=!0,fe(v.customerId),he.current=v.customerId,Fe(Z),Se.current=Z,G.current=me,v.email&&k(v.email),wn===v.customerId)console.log("[useStripeOnramp] SDK already configured for customer:",v.customerId,"\u2014 skipping configure()"),Me.current=Promise.resolve({error:void 0});else {console.log("[useStripeOnramp] configuring SDK with cryptoCustomerId:",v.customerId);let He=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});He.error?console.error("[useStripeOnramp] restore configureSDK error:",He.error.message):wn=v.customerId,Me.current=Promise.resolve(He);}if(R)return;let lt=()=>new Promise(He=>{let ur=()=>{Ye.current&&Ae.current?He():setTimeout(ur,200);};ur();});try{if(await Promise.race([lt(),new Promise((ur,Vt)=>setTimeout(()=>Vt(new Error("timeout")),1e4))]),R)return;let He=Ae.current.toLowerCase();console.log("[useStripeOnramp] re-registering wallet on restore:",He,"network:",Ee.current),await u(He,Ee.current);}catch(He){console.warn("[useStripeOnramp] wallet re-registration on restore failed (non-fatal):",He?.message);}if(R)return;console.log("[useStripeOnramp] credentials restored, skipping to session_params"),b("session_params");}finally{R||c(false);}})(),()=>{R=true;}},[]),useEffect(()=>{if(!e?.publishableKey||!e?.externalUserId||!e?.recipientAddress||Ie||ke)return;let R=false;te(true);async function v(){try{let[H,Z]=await Promise.all([Tu({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?xu({token_address:e.destinationTokenAddress,chain_id:e.destinationChainId,chain_type:e.destinationChainType}).catch(Lt=>(console.warn("[useStripeOnramp] fetchDefaultOnrampToken failed, using chain_id fallback:",Lt?.message),null)):Promise.resolve(null)]);if(R)return;let me=e?.destinationChainType??"ethereum",lt=H.data.find(Lt=>Lt.chain_type===me);if(lt?.address){let Lt=lt.address.toLowerCase();console.log("[resolveWallet] resolved deposit address:",Lt,"recipient:",lt.recipient_address),pt(Lt),Ae.current=Lt,lt.recipient_address&&E(lt.recipient_address);}else console.warn("[resolveWallet] No wallet found for chain_type",me,"in",H.data?.length,"wallets");let He={base:Onramp.CryptoNetwork.base,ethereum:Onramp.CryptoNetwork.ethereum,solana:Onramp.CryptoNetwork.solana,bitcoin:Onramp.CryptoNetwork.bitcoin,polygon:Onramp.CryptoNetwork.polygon},ur={8453:"base",1:"ethereum",137:"polygon"},Vt=Z?.destination_network,sr="none";if(Vt&&He[Vt])oe(He[Vt]),Ee.current=He[Vt],sr=Vt+" (from default_token API)";else if(e?.destinationChainId&&ur[e.destinationChainId]){let Lt=ur[e.destinationChainId];He[Lt]&&(oe(He[Lt]),Ee.current=He[Lt]),sr=Lt+" (from chain_id "+e.destinationChainId+")";}else He[me]&&(oe(He[me]),Ee.current=He[me],sr=me+" (from chain_type fallback)");Z?.destination_currency&&Yt(Z.destination_currency.toLowerCase());let er=Z?.destination_token_metadata,qr=kc(er?.icon_urls,er?.icon_url),Qr=kc(er?.chain?.icon_urls,er?.chain?.icon_url);console.log("[resolveWallet] icon_urls \u2014 token:",qr,"network:",Qr),qr&&xr(qr),Qr&&io(Qr),Ge(!0),Ye.current=!0;}catch(H){console.error("[useStripeOnramp] Failed to resolve wallet:",H?.message),Ge(true),Ye.current=true;}finally{R||te(false);}}return v(),()=>{R=true;}},[e?.publishableKey,e?.externalUserId]);let so=useCallback(async()=>{if(Me.current)return Me.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(v=>(v.error&&(console.error("[useStripeOnramp] configureSDK error:",v.error.message,v.error.code),Me.current=null),v)).catch(v=>{throw console.error("[useStripeOnramp] configureSDK threw:",v?.message??v),Me.current=null,v});return Me.current=R,R},[o,e?.merchantDisplayName]);useEffect(()=>{e?.externalUserId||so();},[]);let Mo=useCallback(async R=>{if(!st.current){st.current=true,y(true),De(),d("Creating auth intent...");try{let v=await bc(R);d("Waiting for authorization...");let H=await i(v);if(H?.error){console.log("[proceedToAuthorize] authorize error:",H.error.message),O("authorization_error","Something went wrong during authorization. Please try again."),b("email");return}if(H?.status==="Denied"){O("authorization_error","Authorization denied by user."),b("email");return}if(H?.status!=="Consented"||!H.customerId){O("authorization_error","Authorization was canceled."),b("email");return}d("Exchanging tokens...");let Z=await bu(v),me=H.customerId,lt=Z.access_token,He=un(Z);console.log("[useStripeOnramp] customerId:",me),console.log("[useStripeOnramp] accessToken acquired, length:",lt.length),fe(me),he.current=me,wn=me,Fe(lt),Si(me,lt,He,Z.expires_in??3600),d("Checking verification status...");try{let ur=await Wa(me,lt),Vt=ur.verifications.find(pn=>pn.name==="kyc_verified"),sr=ur.verifications.find(pn=>pn.name==="id_document_verified"),er=Vt?.status==="verified",qr=Vt?.status==="rejected",Qr=sr?.status==="verified",Lt=ur.provided_fields.includes("first_name");if(d(""),qr&&!Lt)O("kyc_error","KYC was previously rejected. Please submit with correct info."),b("kyc");else if(qr&&Lt)b(Qr?"wallet":"identity");else if(!er&&!Lt)b("kyc");else if(!Qr)b("identity");else if(Ye.current&&Ae.current)try{let pn=Ae.current.toLowerCase();console.log("[proceedToAuthorize] registering wallet:",pn,"network:",se);let ua=await u(pn,se);ua?.error?(console.warn("[proceedToAuthorize] wallet registration error:",ua.error.message),O("wallet_error",ua.error.message,ua.error.code),b("wallet")):(console.log("[proceedToAuthorize] wallet registered successfully"),b("session_params"));}catch(pn){console.warn("[proceedToAuthorize] Inline wallet registration failed, falling back to wallet step:",pn?.message),b("wallet");}else b("wallet");}catch(ur){console.warn("[getOnrampCustomer] failed, defaulting to kyc:",ur?.message),d(""),b("kyc");}}catch(v){O("authorization_error",v?.message??String(v)),b("email");}finally{st.current=false,y(false);}}},[i,De,O,Si,u,se]),q=useCallback(async()=>{if(Keyboard.dismiss(),!x){O("validation_error","Please enter an email address.");return}y(true),De(),d("");try{d("Configuring...");let R=await so();if(R.error){O("configuration_error",R.error.message,R.error.code);return}d("Checking Link account...");let v=await n(x);if(v.error){O("authorization_error",v.error.message,v.error.code);return}v.hasLinkAccount?await Mo(x):(d(""),b("register"));}catch(R){O("unknown_error",R?.message??String(R));}finally{y(false);}},[De,so,x,O,n,Mo]),ie=useCallback(async()=>{if(!I){O("validation_error","Please enter your phone number.");return}y(true),De(),d("");try{d("Creating Link account...");let R=await a({email:x,phone:I,fullName:V||x,country:P||"US"});if(R.error){O("registration_error",R.error.message,R.error.code);return}await Mo(x);}catch(R){O("registration_error",R?.message??String(R));}finally{y(false);}},[De,P,x,O,V,I,a,Mo]);useEffect(()=>{if(g!=="email"||!e?.email||w)return;let R=++Te.current,v=false,H=()=>v||Te.current!==R;return e?.phone?(async()=>{y(true),De();try{d("Configuring...");let Z=await so();if(H())return;if(Z.error){O("configuration_error",Z.error.message,Z.error.code);return}d("Checking Link account...");let me=await n(e.email);if(H())return;if(me.error){O("authorization_error",me.error.message,me.error.code);return}if(me.hasLinkAccount){if(H())return;await Mo(e.email);}else {d("Creating Link account...");let lt=await a({email:e.email,phone:e.phone,fullName:e.email,country:"US"});if(H())return;if(lt.error){O("registration_error",lt.error.message,lt.error.code);return}if(H())return;await Mo(e.email);}}catch(Z){H()||O("unknown_error",Z?.message??String(Z));}finally{y(false);}})():(async()=>{y(true),De();try{d("Configuring...");let Z=await so();if(H())return;if(Z.error){O("configuration_error",Z.error.message,Z.error.code);return}d("Checking Link account...");let me=await n(e.email);if(H())return;if(me.error){O("authorization_error",me.error.message,me.error.code);return}if(me.hasLinkAccount){if(H())return;await Mo(e.email);}else {if(H())return;d(""),b("register");}}catch(Z){H()||O("unknown_error",Z?.message??String(Z));}finally{y(false);}})(),()=>{v=true;}},[g,e?.email,e?.phone,w]);let wt=useCallback(async R=>{y(true),De(),d(""),X(R);try{let v={firstName:R.firstName,lastName:R.lastName,idNumber:R.idNumber||void 0,dateOfBirth:{day:parseInt(R.dobDay,10),month:parseInt(R.dobMonth,10),year:parseInt(R.dobYear,10)},address:{line1:R.addressLine1,line2:R.addressLine2||void 0,city:R.city,state:R.state,postalCode:R.postalCode,country:R.country}},H=await s(v);if(H?.error){if(H.error.stripeErrorCode==="consumer_person_already_verified"){d(""),b("identity");return}O("kyc_error",H.error.message,H.error.stripeErrorCode??H.error.code),b("kyc");return}d("Please review your KYC information...");let Z=await l(null);if(Z?.error){O("kyc_error",Z.error.message,Z.error.stripeErrorCode??Z.error.code),b("kyc");return}if(Z?.status==="UpdateAddress"){O("kyc_error","Please update your address and resubmit."),b("kyc");return}d(""),b("identity");}catch(v){O("kyc_error",v?.message??String(v)),b("kyc");}finally{y(false);}},[s,De,O,l]),Fr=useCallback(async()=>{if(!We.current){We.current=true,y(true),De(),d("Launching identity verification...");try{let R=await m();if(R?.error){O("identity_error",R.error.message,R.error.code);return}d(""),b("wallet");}catch(R){O("identity_error",R?.message??String(R));}finally{We.current=false,y(false);}}},[De,O,m]);useEffect(()=>{g==="identity"&&!C&&Fr();},[g]);let ys=useCallback(async()=>{if(!be){O("validation_error","Please enter a wallet address.");return}y(true),De(),d("");try{let R=be.toLowerCase();console.log("[registerWallet] registering wallet:",R,"network:",se);let v=await u(R,se);if(v?.error){console.warn("[registerWallet] error:",v.error.message),O("wallet_error",v.error.message,v.error.code);return}console.log("[registerWallet] wallet registered successfully"),d(""),b("session_params");}catch(R){O("wallet_error",R?.message??String(R));}finally{y(false);}},[De,O,be,se,u]);useEffect(()=>{g==="wallet"&&Ie&&be&&ys();},[g,Ie,be]);let ao=useCallback(R=>{xe.current=false,at.current=0;let v=0,H=async()=>{v+=1;let Z=Se.current;try{let me=await Su(R,Z);if(console.log(`[pollSessionStatus] poll #${v} session=${R} status="${me.status}"`),xe.current)return;at.current=0,me.status==="fulfillment_complete"?(de(me),b("success")):$t.current=setTimeout(H,3e3);}catch(me){if(xe.current)return;let lt=me?.message??"";if((lt.includes("stripe_onramp_forbidden")||lt.includes("403"))&&(console.log("[pollSessionStatus] token expired during polling, refreshing..."),await ki()&&!xe.current)){$t.current=setTimeout(H,1e3);return}if(at.current+=1,console.error(`[pollSessionStatus] poll #${v} error:`,lt),at.current>=Xf){O("session_error","We couldn't confirm delivery status. Your purchase may still complete \u2014 try again, or close and check your wallet.");return}$t.current=setTimeout(H,5e3);}};$t.current=setTimeout(H,3e3);},[O,ki]),lo=useCallback(()=>{if(ue.current==="processing"&&mt?.id){if(!Se.current){O("session_error","Your session has expired. Your purchase may still complete \u2014 close and check your wallet.");return}De(),at.current=0,$t.current&&(clearTimeout($t.current),$t.current=null),ao(mt.id);}},[De,O,ao,mt?.id]),Dr=useCallback(async R=>{y(true),De(),d("");try{d("Confirming purchase...");let v=await yo(H=>wu(R,H));console.log("[finalizeOnrampSession] confirmed session:",v.id,"status:",v.status),de(v),b("processing"),d(""),console.log("[finalizeOnrampSession] starting fulfillment polling for session:",v.id),ao(v.id);}finally{y(false);}},[De,ao,yo]),zo=useRef(false),Lm=useCallback(async()=>{if(!(!mt||zo.current)){zo.current=true;try{y(!0),De(),d("Refreshing quote...");let R=await yo(v=>wc(mt.id,v));de(R),await Dr(R.id);}catch(R){console.log("[confirmCheckout] error:",R?.message),O("session_error","Something went wrong. Please try again."),b("quote");}finally{y(false),zo.current=false;}}},[De,O,Dr,mt,yo]),zd=useCallback(async()=>{let R=x;if(!R)return console.warn("[reauthorizeLink] no email available for re-authorization"),false;try{console.log("[reauthorizeLink] re-establishing Link session for:",R),d("Verifying identity...");let v=await bc(R),H=await i(v);return H?.status==="Consented"&&H.customerId?(console.log("[reauthorizeLink] re-authorized successfully, customerId:",H.customerId),he.current=H.customerId,fe(H.customerId),wn=H.customerId,!0):(console.warn("[reauthorizeLink] authorize did not consent:",H?.status),!1)}catch(v){return console.warn("[reauthorizeLink] failed:",v?.message),false}},[i,x]),Bm=useCallback(async(R=false,v,H)=>{let Z=v??ve;if(console.log("[collectPaymentMethod] called:",{useApplePay:R,amt:Z,amountOverride:v,sourceAmount:ve,hasSavedToken:!!H}),!Z||isNaN(Number(Z))||Number(Z)<=0){console.log("[collectPaymentMethod] validation failed \u2014 no valid amount"),O("validation_error","Please enter a valid amount.");return}v&&xt(v),y(true),De(),d("");try{let me=await so();if(me.error){O("configuration_error",me.error.message,me.error.code);return}let lt;if(H)console.log("[collectPaymentMethod] using saved payment token"),lt=H;else if(R){if(!e?.merchantIdentifier?.trim()){console.log("[collectPaymentMethod] no merchantIdentifier"),O("configuration_error","Apple Pay is not configured. Pass merchantIdentifier on StripeOnramp or in onramp config."),b("session_params");return}d("Opening Apple Pay..."),console.log("[collectPaymentMethod] calling stripeCollectPM(PlatformPay)...");let Vt={applePay:{merchantCountryCode:"US",currencyCode:ce.toUpperCase(),cartItems:[{paymentType:PlatformPay.PaymentType.Immediate,label:`${ze.toUpperCase()} purchase + fees`,amount:Z}]}},sr=await h("PlatformPay",Vt);if(console.log("[collectPaymentMethod] PlatformPay result ok:",!sr?.error),sr?.error){let qr=sr.error.message??"",Qr=sr.error.code??"",Lt=/cancel/i.test(qr)||/cancel/i.test(Qr);console.log("[collectPaymentMethod] pmResult error:",sr.error,"isCancellation:",Lt),Lt||(O("payment_error",qr,Qr),b("session_params"));return}if(!sr?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}d("Creating payment token...");let er=await S();if(console.log("[collectPaymentMethod] tokenResult ok:",!er?.error),er?.error){O("payment_error",er.error.message,er.error.code),b("session_params");return}lt=er.cryptoPaymentToken;}else {d("Select a payment method...");let Vt=await h("Card");if(console.log("[collectPaymentMethod] Card result ok:",!Vt?.error),Vt?.error){let qr=Vt.error.message??"",Qr=Vt.error.code??"",Lt=/cancel/i.test(qr)||/cancel/i.test(Qr);console.log("[collectPaymentMethod] pmResult error:",Vt.error,"isCancellation:",Lt),Lt||(O("payment_error",qr,Qr),b("session_params"));return}if(!Vt?.displayData){console.log("[collectPaymentMethod] no displayData \u2014 canceled");return}let sr=Vt.displayData;console.log("[collectPaymentMethod] displayData:",{type:sr.type,label:sr.label,sublabel:sr.sublabel,hasIcon:!!sr.icon}),d("Creating payment token...");let er=await S();if(console.log("[collectPaymentMethod] tokenResult ok:",!er?.error),er?.error){O("payment_error",er.error.message,er.error.code),b("session_params");return}lt=er.cryptoPaymentToken;}d("Creating onramp session..."),console.log("[collectPaymentMethod] creating onramp session, walletAddress:",be,"walletAddressRef:",Ae.current);let He=Ae.current||be.toLowerCase(),ur=await yo(Vt=>Cu({cryptoCustomerId:he.current,paymentToken:lt,sourceAmount:Number(Z),sourceCurrency:ce,destinationCurrency:ze,walletAddress:He,destinationNetwork:se},Vt));console.log("[collectPaymentMethod] session created:",ur?.id,"useApplePay:",R),de(ur),d(""),R?(console.log("[collectPaymentMethod] finalizing Apple Pay session..."),await Dr(ur.id),console.log("[collectPaymentMethod] confirmation done, polling for fulfillment in background")):b("quote");}catch(me){console.log("[collectPaymentMethod] error caught:",me?.message),O("session_error","Something went wrong. Please try again."),b("session_params");}finally{y(false),d("");}},[De,so,h,S,ze,O,Dr,xt,ve,ce,be,se,yo,e?.merchantIdentifier]),Wm=useCallback(async()=>{y(true),De(),d("Select a payment method...");try{let R=await so();if(R.error)return O("configuration_error",R.error.message,R.error.code),null;let v=await h("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 zd())return O("authorization_error","Please verify your identity to add a payment method."),null;v=await h("Card"),console.log("[addPaymentMethod] Card result after re-auth ok:",!v?.error);}if(v?.error){let me=v.error.message??"",lt=v.error.code??"",He=/cancel/i.test(me)||/cancel/i.test(lt);return console.log("[addPaymentMethod] pmResult error:",v.error,"isCancellation:",He),He||O("payment_error",me,lt),null}if(!v?.displayData)return console.log("[addPaymentMethod] no displayData \u2014 canceled"),null;let H=v.displayData;console.log("[addPaymentMethod] displayData:",{type:H.type,label:H.label,sublabel:H.sublabel,hasIcon:!!H.icon}),d("Saving payment method...");let Z=await S();return console.log("[addPaymentMethod] tokenResult ok:",!Z?.error),Z?.error?(O("payment_error",Z.error.message,Z.error.code),null):(console.log("[addPaymentMethod] payment method added successfully"),{token:Z.cryptoPaymentToken,sublabel:H.sublabel??""})}catch(R){return console.log("[addPaymentMethod] error:",R?.message),O("session_error",R?.message??String(R)),null}finally{y(false),d("");}},[De,so,h,S,O,zd]),Am=useCallback(async()=>{if(mt){y(true),De(),d("");try{let R=await yo(v=>wc(mt.id,v));de(R);}catch(R){console.log("[refreshQuote] error:",R?.message),O("session_error","Something went wrong. Please try again.");}finally{y(false);}}},[De,O,mt,yo]),Em=useCallback(()=>{xe.current=true,at.current=0,$t.current&&(clearTimeout($t.current),$t.current=null),b(r),y(false),d(""),_(null),k(e?.email??""),A(e?.phone??""),F(""),W("US"),fe(""),he.current="",Fe(""),Se.current="",G.current="",Ge(false),te(false),X(Ru),pt(e?.recipientAddress??""),Ae.current="",Ye.current=false,oe(Onramp.CryptoNetwork.ethereum),xt(e?.defaultSourceAmount??"100"),ae(e?.defaultSourceCurrency??"usd"),Yt(e?.defaultDestinationCurrency??"usdc"),E(""),xr(void 0),io(void 0),de(null),Te.current+=1,st.current=false,We.current=false;},[e,r]);return {step:g,restoring:w,loading:C,status:f,error:T,email:x,phone:I,fullName:V,country:P,customerId:$,accessToken:Ke,session:mt,kycData:pe,walletAddress:be,resolvedRecipientAddress:z,walletNetwork:se,sourceAmount:ve,sourceCurrency:ce,destinationCurrency:ze,tokenIconUrl:et,networkIconUrl:_t,applePaySupported:Or,walletReady:Ie,walletLoading:ke,setStep:b,setStatus:d,setEmail:k,setPhone:A,setFullName:F,setCountry:W,setWalletAddress:pt,setWalletNetwork:oe,setSourceAmount:xt,setSourceCurrency:ae,setDestinationCurrency:Yt,checkEmail:q,register:ie,attachKyc:wt,verifyIdentity:Fr,registerWallet:ys,collectPaymentMethod:Bm,addPaymentMethod:Wm,refreshQuote:Am,confirmCheckout:Lm,reset:Em,clearError:De,emitComplete:ft,resumeFulfillmentPolling:lo,amountFirst:t}}function Iu({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(Jt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(ht,{size:56,strokeWidth:3}),jsx(wr,{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(Jt,{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(ht,{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(wr,{error:n,progress:a,loading:o})]})]})})}function Pu({styles:e,loading:t,status:r,error:o,verifyIdentity:n,onClose:a}){return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:a}),jsxs(View,{style:e.flow.centered,children:[t?jsxs(Fragment,{children:[jsx(View,{style:e.flow.spinnerWrap,children:jsx(ht,{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(wr,{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 Fu({styles:e,error:t,status:r,loading:o,sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,onClose:m,onRetryStatusCheck:u}){let{colors:h}=D(),S=!!t;return jsxs(View,{style:e.form.screen,children:[S?jsx(Jt,{onPress:m}):jsx(View,{style:va}),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(ht,{size:48,strokeWidth:3,gradientFrom:h.primary,gradientTo:h.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(Oa,{sourceCurrency:n,destinationCurrency:a,destinationNetwork:i,tokenIconUrl:s,networkIconUrl:l,style:{marginTop:24,marginHorizontal:24}})]})}),jsxs(View,{style:e.form.footer,children:[jsx(wr,{error:t,progress:r,loading:o}),t?jsx(TouchableOpacity,{style:e.form.ghostBtn,onPress:u,children:jsx(Text,{style:e.form.ghostBtnText,children:"Check status again"})}):null]})]})}function Du({styles:e,session:t,loading:r,error:o,status:n,confirmCheckout:a,tokenIconUrl:i,networkIconUrl:s,onClose:l,onBack:m}){let{colors:u}=D(),h=t.transaction_details,S=Ra(h.destination_amount,h.destination_currency);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{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(cu,{currency:h.destination_currency,tokenIconUrl:i,networkIconUrl:s,size:64})}),jsxs(View,{style:e.quote.card,children:[jsx(co,{quote:e.quote,label:"You pay",value:`${h.source_amount} ${h.source_currency.toUpperCase()}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"You receive",value:`${S} ${h.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"Network fee",value:`$${h.fees.network_fee_amount}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"Transaction fee",value:`$${h.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(ht,{size:28,strokeWidth:2,gradientFrom:u.primaryForeground,gradientTo:u.primaryForeground})}):jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:a,children:jsx(Text,{style:e.form.continueBtnText,children:"Confirm Purchase"})}),jsx(wr,{error:o,progress:n,loading:r})]})]})}function Vu({styles:e,hasPrefilledPhone:t,loading:r,error:o,status:n,email:a,phone:i,setPhone:s,register:l,onClose:m}){let u=D();return t?jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:m}),jsxs(View,{style:e.flow.centered,children:[jsx(ht,{size:56,strokeWidth:3}),jsx(wr,{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(Jt,{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:u.components.input.placeholderColor,keyboardType:"phone-pad",value:i,onChangeText:h=>s(h.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(ht,{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(wr,{error:o,progress:n,loading:r})]})]})})}function hh({currency:e,tokenIconUrl:t,size:r=72}){let{colors:o}=D(),n=e.toLowerCase(),a=Pa[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:[xo.tokenCircle,{width:r,height:r,borderRadius:r/2,backgroundColor:a}],children:jsx(Text,{style:[xo.tokenLetter,{fontSize:r*.38}],children:e.toUpperCase().slice(0,e.length>3?4:void 0)})}),jsx(View,{style:[xo.checkBadge,{width:i,height:i,borderRadius:i/2,backgroundColor:o.success,borderColor:o.background}],children:jsx(qe,{size:i*.55,color:"#FFFFFF",strokeWidth:3})})]})}function Lu({styles:e,session:t,resolvedRecipientAddress:r,recipientFromConfig:o,tokenIconUrl:n,networkIconUrl:a,onDone:i}){let {colors:s,components:l,fonts:m}=D(),u=t.transaction_details,h=Ra(u.destination_amount,u.destination_currency),S=r||o||"";Ia(u.destination_network);return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:i,title:"Purchase complete"}),jsx(View,{style:e.form.content,children:jsxs(BottomSheetScrollView,{style:e.form.flex,contentContainerStyle:xo.scrollContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:xo.iconSection,children:[jsx(hh,{currency:u.destination_currency,tokenIconUrl:n,size:72}),jsxs(View,{style:xo.statusRow,children:[jsx(View,{style:[xo.statusDot,{backgroundColor:s.success}]}),jsx(Text,{style:[xo.statusText,{color:s.foreground,fontFamily:m.semibold}],children:"Completed"})]}),jsx(Text,{style:[xo.subtitle,{color:s.foregroundMuted}],children:"Your crypto is on its way to your wallet."})]}),jsx(Oa,{sourceCurrency:u.source_currency,destinationCurrency:u.destination_currency,destinationNetwork:u.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},xo.detailCard],children:[jsx(co,{quote:e.quote,label:"You Paid",value:`${u.source_amount} ${u.source_currency.toUpperCase()}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"You Received",value:`${h} ${u.destination_currency.toUpperCase()}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"Network Fee",value:`$${u.fees.network_fee_amount}`,hideDivider:true}),jsx(co,{quote:e.quote,label:"Transaction Fee",value:`$${u.fees.transaction_fee_amount}`,hideDivider:true}),jsx(uc,{quote:e.quote,label:"Intent Address",address:u.wallet_address,hideDivider:true}),S?jsx(uc,{quote:e.quote,label:"Recipient Address",address:S,last:true}):jsx(co,{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 xo=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 Bu({styles:e,hasAutoWallet:t,loading:r,error:o,status:n,walletAddress:a,walletNetwork:i,setWalletAddress:s,setWalletNetwork:l,setDestinationCurrency:m,registerWallet:u,onClose:h}){let{components:S}=D();if(t){let g=!r&&!!o;return jsxs(View,{style:e.form.screen,children:[jsx(Jt,{onPress:h}),jsxs(View,{style:e.flow.centered,children:[!g&&jsx(ht,{size:56,strokeWidth:3}),jsx(wr,{error:o,progress:n,loading:r})]}),g&&jsx(View,{style:e.form.footer,children:jsx(TouchableOpacity,{style:e.form.continueBtn,onPress:u,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(Jt,{onPress:h}),jsxs(View,{style:e.form.content,children:[jsx(Text,{style:e.form.title,children:"Your crypto wallet"}),jsx(Text,{style:e.form.subtitle,children:"Enter the wallet address where you'd like to receive your crypto."}),jsxs(View,{style:e.form.fieldWrap,children:[jsx(Text,{style:e.form.fieldLabel,children:"Wallet address"}),jsx(TextInput,{style:[e.form.input,e.wallet.input],placeholder:"0x...",placeholderTextColor:S.input.placeholderColor,autoCapitalize:"none",autoCorrect:false,value: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:_a.map(g=>{let b=i===g.value;return jsxs(TouchableOpacity,{style:[e.wallet.row,b&&e.wallet.rowSelected],onPress:()=>{l(g.value),m(g.defaultCrypto);},children:[jsx(View,{style:e.wallet.iconWrap,children:jsx(g.Icon,{size:24})}),jsx(Text,{style:[e.wallet.rowText,b&&e.wallet.rowTextSelected],children:g.label}),b&&jsx(View,{style:e.wallet.checkCircle,children:jsx(qe,{size:14,color:S.container.buttonTitleColor,strokeWidth:2.5})})]},g.value)})})]})]}),jsxs(View,{style:e.form.footer,children:[r?jsx(View,{style:[e.form.continueBtn,e.form.loaderInButton],children:jsx(ht,{size:28,strokeWidth:2})}):jsx(TouchableOpacity,{style:[e.form.continueBtn,!a&&e.form.continueBtnDisabled],onPress:u,disabled:!a,children:jsx(Text,{style:[e.form.continueBtnText,!a&&e.form.continueBtnTextDisabled],children:"Continue"})}),jsx(wr,{error:o,progress:n,loading:r})]})]})})}function Ha({config:e,onClose:t}){let r=D(),o=Li(),{step:n,restoring:a,loading:i,status:s,error:l,email:m,phone:u,session:h,kycData:S,walletAddress:g,resolvedRecipientAddress:b,walletNetwork:w,sourceAmount:c,sourceCurrency:C,destinationCurrency:y,tokenIconUrl:f,networkIconUrl:d,applePaySupported:T,setStep:_,setEmail:x,setPhone:k,setWalletAddress:I,setWalletNetwork:A,setSourceAmount:V,setDestinationCurrency:F,checkEmail:P,register:W,attachKyc:$,verifyIdentity:fe,registerWallet:Ke,collectPaymentMethod:Fe,addPaymentMethod:G,confirmCheckout:Se,reset:he,emitComplete:Ie,resumeFulfillmentPolling:Ge,amountFirst:ke,customerId:te,accessToken:Te}=Aa(e),st=!!e?.email,We=!!e?.phone,Ye=!!e?.publishableKey&&!!e?.externalUserId,[Ae,Ee]=useState(void 0),[Me,pe]=useState([]);useEffect(()=>{if(n!=="session_params"||!te||!Te)return;console.log("[OnrampScreen] customerId:",te);let E=oe=>{let ve=oe?.message??"";return ve.includes("stripe_onramp_forbidden")||ve.includes("403")},se=oe=>{E(oe)&&(bn(),he());};Wa(te,Te).then(oe=>{console.log("[OnrampScreen] customer fetched, id:",oe?.id);}).catch(oe=>{console.warn("[OnrampScreen] customer fetch error:",oe?.message),se(oe);}),Sc(te,Te).then(oe=>{console.log("[OnrampScreen] payment_tokens fetched, count:",oe.data?.length??0),pe(oe.data??[]);}).catch(oe=>{console.warn("[OnrampScreen] payment_tokens error:",oe?.message),se(oe);}),console.log("[OnrampScreen] walletAddress:",g,"walletNetwork:",w),g&&(console.log("[OnrampScreen] calling getTransactionLimits..."),ku({destinationNetwork:w||"ethereum",walletAddress:g,accessToken:Te,cryptoCustomerId:te}).then(oe=>{console.log("[OnrampScreen] transaction_limits fetched");let ve=oe.limits?.usd;if(ve?.card?.length){let xt=Math.max(...ve.card.map(ce=>ce.limit));Ee(xt),console.log("[OnrampScreen] card max amount:",xt);}}).catch(oe=>{console.warn("[OnrampScreen] transaction_limits error:",oe?.message),se(oe);}));},[n,te,Te,g,w,he]);let X=async()=>{if(!(!te||!Te))try{let E=await Sc(te,Te);console.log("[OnrampScreen] payment_tokens refreshed, count:",E.data?.length??0),pe(E.data??[]);}catch(E){console.warn("[OnrampScreen] payment_tokens refresh error:",E?.message);let se=E?.message??"";(se.includes("stripe_onramp_forbidden")||se.includes("403"))&&(bn(),he());}},be=async()=>{let E=await G();return E&&await X(),E},pt=e?.skipSuccessConfirmation===true;useEffect(()=>{n==="success"&&pt&&h&&(Ie(h),he(),t?.());},[n,pt,h,Ie,he,t]);let z=()=>{he(),t?.();};return a?jsx(View,{style:[Sh.container,{backgroundColor:r.colors.background}],children:jsx(ht,{size:56,strokeWidth:3,gradientFrom:r.colors.primary,gradientTo:r.colors.primary})}):n==="email"?jsx(Iu,{styles:o,placeholderColor:r.components.input.placeholderColor,hasPrefilledEmail:st,loading:i,error:l,status:s,email:m,setEmail:x,checkEmail:P,onClose:z}):n==="register"?jsx(Vu,{styles:o,hasPrefilledPhone:We,loading:i,error:l,status:s,email:m,phone:u,setPhone:k,register:W,onClose:z}):n==="kyc"?jsx(Da,{initialData:S,loading:i,onComplete:$,onCancel:()=>_("email")}):n==="identity"?jsx(Pu,{styles:o,loading:i,status:s,error:l,verifyIdentity:fe,onClose:z}):n==="wallet"?jsx(Bu,{styles:o,hasAutoWallet:Ye,loading:i,error:l,status:s,walletAddress:g,walletNetwork:w,setWalletAddress:I,setWalletNetwork:A,setDestinationCurrency:F,registerWallet:Ke,onClose:z}):n==="session_params"?jsx(Fa,{initialAmount:c,currency:C,applePaySupported:T,paymentSelectorPosition:e?.paymentSelectorPosition??"header",maxAmount:Ae,paymentTokens:Me,onAddPaymentMethod:be,onCollectPayment:(E,se)=>{Fe(E,se);},paymentLoading:i,paymentStatus:s,paymentError:l?.message??null,onConfirm:(E,se)=>{if(console.log("[OnrampScreen] onConfirm called:",{amount:E,selectedMethod:se,amountFirst:ke}),ke&&!te)V(E),_("email");else {let oe=se==="apple_pay",ve=!oe&&se?se:void 0;console.log("[OnrampScreen] isApplePay:",oe,"hasSavedToken:",!!ve),Fe(oe,E,ve);}},onCancel:z}):n==="quote"&&h?jsx(Du,{styles:o,session:h,loading:i,error:l,status:s,confirmCheckout:Se,tokenIconUrl:f,networkIconUrl:d,onClose:z,onBack:()=>_("session_params")}):n==="processing"?jsx(Fu,{styles:o,error:l,status:s,loading:i,sourceCurrency:h?.transaction_details.source_currency,destinationCurrency:h?.transaction_details.destination_currency??y,destinationNetwork:h?.transaction_details.destination_network??"base",tokenIconUrl:f,networkIconUrl:d,onClose:z,onRetryStatusCheck:Ge}):n==="success"&&h&&!pt?jsx(Lu,{styles:o,session:h,resolvedRecipientAddress:b,recipientFromConfig:e?.recipientAddress,tokenIconUrl:f,networkIconUrl:d,onDone:()=>{Ie(h),he(),t?.();}}):null}var Sh=StyleSheet.create({container:{flex:1,justifyContent:"center",alignItems:"center"}});function Eu(){try{let e=kh.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 Na({publishableKey:e,email:t,phone:r,externalUserId:o,flowOrder:n,destinationChainType:a="ethereum",destinationChainId:i="8453",destinationTokenAddress:s,recipientAddress:l,onComplete:m,onError:u,onStepChange:h,onClose:S,merchantIdentifier:g="",urlScheme:b="unifoldOnramp",paymentSelectorPosition:w,skipSuccessConfirmation:c=false}){let{colors:C,fonts:y,components:f}=D(),d=e||Ca(),T=useMemo(()=>{let V=g.trim();return V.length>0?V:Eu()??""},[g]),[_,x]=useState("loading"),[k,I]=useState(null);useEffect(()=>{let V=false;async function F(){try{d&&(Va(d),La(_s()));let P=await Ba();if(V)return;let W=T.trim();if(await initStripe({publishableKey:P,urlScheme:b,...W?{merchantIdentifier:W}:{}}),V)return;x("ready");}catch(P){if(V)return;console.error("[StripeOnramp] Init failed:",P),I(P?.message??"Failed to load Stripe configuration"),x("error");}}return F(),()=>{V=true;}},[d,T,b]);let A=useMemo(()=>{let V={publishableKey:d,externalUserId:o,destinationChainType:a,destinationChainId:i,onComplete:m,onError:u,onStepChange:h};return s&&(V.destinationTokenAddress=s),l&&(V.recipientAddress=l),t&&(V.email=t),r&&(V.phone=r),n&&(V.flowOrder=n),w&&(V.paymentSelectorPosition=w),V.skipSuccessConfirmation=c,V.merchantIdentifier=T,V},[d,o,a,i,s,l,t,r,n,w,c,T,m,u,h]);return _==="error"?jsxs(View,{style:[Mi.centered,{backgroundColor:C.background}],children:[jsx(Text,{style:[Mi.errorText,{color:C.error,fontFamily:y.medium}],children:"Unable to initialize"}),jsx(Text,{style:[Mi.errorDetail,{color:C.foregroundMuted,fontFamily:y.regular}],children:k}),S&&jsx(TouchableOpacity,{style:[Mi.retryBtn,{backgroundColor:f.button.primaryBackground,borderRadius:f.button.borderRadius}],onPress:S,children:jsx(Text,{style:[Mi.retryBtnText,{color:f.button.primaryText,fontFamily:y.medium}],children:"Go Back"})})]}):_==="loading"?jsx(View,{style:[Mi.centered,{backgroundColor:C.background}],children:jsx(ht,{size:56,strokeWidth:3,gradientFrom:C.primary,gradientTo:C.primary})}):jsx(Ha,{config:A,onClose:S})}var Mi=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 Hu(){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 Nu="__unifold_stripe_onramp__";function ja(e){globalThis[Nu]=e;}function ju(){return globalThis[Nu]}ja(Na);var _o=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 Yn,Tn,zi,$u,Fh=($u=class extends _o{constructor(){super();Y(this,Yn);Y(this,Tn);Y(this,zi);B(this,zi,t=>{if(typeof window<"u"&&window.addEventListener){let r=()=>t();return window.addEventListener("visibilitychange",r,false),()=>{window.removeEventListener("visibilitychange",r);}}});}onSubscribe(){p(this,Tn)||this.setEventListener(p(this,zi));}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,Tn))==null||t.call(this),B(this,Tn,void 0));}setEventListener(t){var r;B(this,zi,t),(r=p(this,Tn))==null||r.call(this),B(this,Tn,t(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus();}));}setFocused(t){p(this,Yn)!==t&&(B(this,Yn,t),this.onFocus());}onFocus(){let t=this.isFocused();this.listeners.forEach(r=>{r(t);});}isFocused(){return typeof p(this,Yn)=="boolean"?p(this,Yn):globalThis.document?.visibilityState!=="hidden"}},Yn=new WeakMap,Tn=new WeakMap,zi=new WeakMap,$u),Ui=new Fh;var Dh={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Ro,Jn,qu,Vh=(qu=class{constructor(){Y(this,Ro,Dh);Y(this,Jn,false);}setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&p(this,Jn)&&e!==p(this,Ro)&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:p(this,Ro),provider:e}),B(this,Ro,e),process.env.NODE_ENV!=="production"&&B(this,Jn,false);}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&B(this,Jn,true),p(this,Ro).setTimeout(e,t)}clearTimeout(e){p(this,Ro).clearTimeout(e);}setInterval(e,t){return process.env.NODE_ENV!=="production"&&B(this,Jn,true),p(this,Ro).setInterval(e,t)}clearInterval(e){p(this,Ro).clearInterval(e);}},Ro=new WeakMap,Jn=new WeakMap,qu),Io=new Vh;function Qu(e){setTimeout(e,0);}var Pc=typeof window>"u"||"Deno"in globalThis;function Kt(){}function Yu(e,t){return typeof e=="function"?e(t):e}function As(e){return typeof e=="number"&&e>=0&&e!==1/0}function qa(e,t){return Math.max(e+(t||0)-Date.now(),0)}function mo(e,t){return typeof e=="function"?e(t):e}function Rr(e,t){return typeof e=="function"?e(t):e}function Qa(e,t){let{type:r="all",exact:o,fetchStatus:n,predicate:a,queryKey:i,stale:s}=e;if(i){if(o){if(t.queryHash!==Es(i,t.options))return false}else if(!ei(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 Ka(e,t){let{exact:r,status:o,predicate:n,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return false;if(r){if(Zn(t.options.mutationKey)!==Zn(a))return false}else if(!ei(t.options.mutationKey,a))return false}return !(o&&t.state.status!==o||n&&!n(t))}function Es(e,t){return (t?.queryKeyHashFn||Zn)(e)}function Zn(e){return JSON.stringify(e,(t,r)=>vc(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function ei(e,t){return e===t?true:typeof e!=typeof t?false:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>ei(e[r],t[r])):false}var Lh=Object.prototype.hasOwnProperty;function $a(e,t,r=0){if(e===t)return e;if(r>500)return t;let o=Ku(e)&&Ku(t);if(!o&&!(vc(e)&&vc(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 u=0;u<s;u++){let h=o?u:i[u],S=e[h],g=t[h];if(S===g){l[h]=S,(o?u<a:Lh.call(e,h))&&m++;continue}if(S===null||g===null||typeof S!="object"||typeof g!="object"){l[h]=g;continue}let b=$a(S,g,r+1);l[h]=b,b===S&&m++;}return a===s&&m===a?e:l}function Ga(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 Ku(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function vc(e){if(!Gu(e))return false;let t=e.constructor;if(t===void 0)return true;let r=t.prototype;return !(!Gu(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Gu(e){return Object.prototype.toString.call(e)==="[object Object]"}function Ju(e){return new Promise(t=>{Io.setTimeout(t,e);})}function Ms(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 $a(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 $a(e,t)}return t}function Zu(e,t,r=0){let o=[...e,t];return r&&o.length>r?o.slice(1):o}function Xu(e,t,r=0){let o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var Xn=Symbol();function Ya(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Xn&&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===Xn?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ja(e,t){return typeof e=="function"?e(...t):!!e}function ep(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 vo=(()=>{let e=()=>Pc;return {isServer(){return e()},setIsServer(t){e=t;}}})();function zs(){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 tp=Qu;function Bh(){let e=[],t=0,r=s=>{s();},o=s=>{s();},n=tp,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 St=Bh();var Hi,xn,Ni,rp,Wh=(rp=class extends _o{constructor(){super();Y(this,Hi,true);Y(this,xn);Y(this,Ni);B(this,Ni,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(){p(this,xn)||this.setEventListener(p(this,Ni));}onUnsubscribe(){var t;this.hasListeners()||((t=p(this,xn))==null||t.call(this),B(this,xn,void 0));}setEventListener(t){var r;B(this,Ni,t),(r=p(this,xn))==null||r.call(this),B(this,xn,t(this.setOnline.bind(this)));}setOnline(t){p(this,Hi)!==t&&(B(this,Hi,t),this.listeners.forEach(o=>{o(t);}));}isOnline(){return p(this,Hi)}},Hi=new WeakMap,xn=new WeakMap,Ni=new WeakMap,rp),ji=new Wh;function Ah(e){return Math.min(1e3*2**e,3e4)}function Oc(e){return (e??"online")==="online"?ji.isOnline():true}var Za=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent;}};function Xa(e){let t=false,r=0,o,n=zs(),a=()=>n.status!=="pending",i=w=>{if(!a()){let c=new Za(w);S(c),e.onCancel?.(c);}},s=()=>{t=true;},l=()=>{t=false;},m=()=>Ui.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),u=()=>Oc(e.networkMode)&&e.canRun(),h=w=>{a()||(o?.(),n.resolve(w));},S=w=>{a()||(o?.(),n.reject(w));},g=()=>new Promise(w=>{o=c=>{(a()||m())&&w(c);},e.onPause?.();}).then(()=>{o=void 0,a()||e.onContinue?.();}),b=()=>{if(a())return;let w,c=r===0?e.initialPromise:void 0;try{w=c??e.fn();}catch(C){w=Promise.reject(C);}Promise.resolve(w).then(h).catch(C=>{if(a())return;let y=e.retry??(vo.isServer()?0:3),f=e.retryDelay??Ah,d=typeof f=="function"?f(r,C):f,T=y===true||typeof y=="number"&&r<y||typeof y=="function"&&y(r,C);if(t||!T){S(C);return}r++,e.onFail?.(r,C),Ju(d).then(()=>m()?void 0:g()).then(()=>{t?S(C):b();});});};return {promise:n,status:()=>n.status,cancel:i,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:u,start:()=>(u()?b():g().then(b),n)}}var ti,op,el=(op=class{constructor(){Y(this,ti);}destroy(){this.clearGcTimeout();}scheduleGc(){this.clearGcTimeout(),As(this.gcTime)&&B(this,ti,Io.setTimeout(()=>{this.optionalRemove();},this.gcTime));}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(vo.isServer()?1/0:300*1e3));}clearGcTimeout(){p(this,ti)!==void 0&&(Io.clearTimeout(p(this,ti)),B(this,ti,void 0));}},ti=new WeakMap,op);var ri,$i,to,oi,rr,Us,ni,Hr,lp,Qo,sp,ap=(sp=class extends el{constructor(t){super();Y(this,Hr);Y(this,ri);Y(this,$i);Y(this,to);Y(this,oi);Y(this,rr);Y(this,Us);Y(this,ni);B(this,ni,false),B(this,Us,t.defaultOptions),this.setOptions(t.options),this.observers=[],B(this,oi,t.client),B(this,to,p(this,oi).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,B(this,ri,ip(this.options)),this.state=t.state??p(this,ri),this.scheduleGc();}get meta(){return this.options.meta}get promise(){return p(this,rr)?.promise}setOptions(t){if(this.options={...p(this,Us),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=ip(this.options);r.data!==void 0&&(this.setState(np(r.data,r.dataUpdatedAt)),B(this,ri,r));}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&p(this,to).remove(this);}setData(t,r){let o=Ms(this.state.data,t,this.options);return Le(this,Hr,Qo).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(t,r){Le(this,Hr,Qo).call(this,{type:"setState",state:t,setStateOptions:r});}cancel(t){let r=p(this,rr)?.promise;return p(this,rr)?.cancel(t),r?r.then(Kt).catch(Kt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:true});}get resetState(){return p(this,ri)}reset(){this.destroy(),this.setState(this.resetState);}isActive(){return this.observers.some(t=>Rr(t.options.enabled,this)!==false)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Xn||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>mo(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:!qa(this.state.dataUpdatedAt,t)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:false}),p(this,rr)?.continue();}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:false}),p(this,rr)?.continue();}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),p(this,to).notify({type:"observerAdded",query:this,observer:t}));}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(r=>r!==t),this.observers.length||(p(this,rr)&&(p(this,ni)||Le(this,Hr,lp).call(this)?p(this,rr).cancel({revert:true}):p(this,rr).cancelRetry()),this.scheduleGc()),p(this,to).notify({type:"observerRemoved",query:this,observer:t}));}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||Le(this,Hr,Qo).call(this,{type:"invalidate"});}async fetch(t,r){if(this.state.fetchStatus!=="idle"&&p(this,rr)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:true});else if(p(this,rr))return p(this,rr).continueRetry(),p(this,rr).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:()=>(B(this,ni,true),o.signal)});},a=()=>{let l=Ya(this.options,r),u=(()=>{let h={client:p(this,oi),queryKey:this.queryKey,meta:this.meta};return n(h),h})();return B(this,ni,false),this.options.persister?this.options.persister(l,u,this):l(u)},s=(()=>{let l={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:p(this,oi),state:this.state,fetchFn:a};return n(l),l})();this.options.behavior?.onFetch(s,this),B(this,$i,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==s.fetchOptions?.meta)&&Le(this,Hr,Qo).call(this,{type:"fetch",meta:s.fetchOptions?.meta}),B(this,rr,Xa({initialPromise:r?.initialPromise,fn:s.fetchFn,onCancel:l=>{l instanceof Za&&l.revert&&this.setState({...p(this,$i),fetchStatus:"idle"}),o.abort();},onFail:(l,m)=>{Le(this,Hr,Qo).call(this,{type:"failed",failureCount:l,error:m});},onPause:()=>{Le(this,Hr,Qo).call(this,{type:"pause"});},onContinue:()=>{Le(this,Hr,Qo).call(this,{type:"continue"});},retry:s.options.retry,retryDelay:s.options.retryDelay,networkMode:s.options.networkMode,canRun:()=>true}));try{let l=await p(this,rr).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),p(this,to).config.onSuccess?.(l,this),p(this,to).config.onSettled?.(l,this.state.error,this),l}catch(l){if(l instanceof Za){if(l.silent)return p(this,rr).promise;if(l.revert){if(this.state.data===void 0)throw l;return this.state.data}}throw Le(this,Hr,Qo).call(this,{type:"error",error:l}),p(this,to).config.onError?.(l,this),p(this,to).config.onSettled?.(this.state.data,l,this),l}finally{this.scheduleGc();}}},ri=new WeakMap,$i=new WeakMap,to=new WeakMap,oi=new WeakMap,rr=new WeakMap,Us=new WeakMap,ni=new WeakMap,Hr=new WeakSet,lp=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Qo=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,...Fc(o.data,this.options),fetchMeta:t.meta??null};case "success":let n={...o,...np(t.data,t.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return B(this,$i,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),St.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate();}),p(this,to).notify({query:this,type:"updated",action:t});});},sp);function Fc(e,t){return {fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Oc(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function np(e,t){return {data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:false,status:"success"}}function ip(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 Ir,Ne,Ns,Sr,ii,qi,Ko,_n,js,Qi,Ki,si,ai,Rn,Gi,ot,Hs,Dc,Vc,Lc,Bc,Wc,Ac,Ec,pp,up,zc=(up=class extends _o{constructor(t,r){super();Y(this,ot);Y(this,Ir);Y(this,Ne);Y(this,Ns);Y(this,Sr);Y(this,ii);Y(this,qi);Y(this,Ko);Y(this,_n);Y(this,js);Y(this,Qi);Y(this,Ki);Y(this,si);Y(this,ai);Y(this,Rn);Y(this,Gi,new Set);this.options=r,B(this,Ir,t),B(this,_n,null),B(this,Ko,zs()),this.bindMethods(),this.setOptions(r);}bindMethods(){this.refetch=this.refetch.bind(this);}onSubscribe(){this.listeners.size===1&&(p(this,Ne).addObserver(this),cp(p(this,Ne),this.options)?Le(this,ot,Hs).call(this):this.updateResult(),Le(this,ot,Bc).call(this));}onUnsubscribe(){this.hasListeners()||this.destroy();}shouldFetchOnReconnect(){return Mc(p(this,Ne),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Mc(p(this,Ne),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,Le(this,ot,Wc).call(this),Le(this,ot,Ac).call(this),p(this,Ne).removeObserver(this);}setOptions(t){let r=this.options,o=p(this,Ne);if(this.options=p(this,Ir).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof Rr(this.options.enabled,p(this,Ne))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");Le(this,ot,Ec).call(this),p(this,Ne).setOptions(this.options),r._defaulted&&!Ga(this.options,r)&&p(this,Ir).getQueryCache().notify({type:"observerOptionsUpdated",query:p(this,Ne),observer:this});let n=this.hasListeners();n&&dp(p(this,Ne),o,this.options,r)&&Le(this,ot,Hs).call(this),this.updateResult(),n&&(p(this,Ne)!==o||Rr(this.options.enabled,p(this,Ne))!==Rr(r.enabled,p(this,Ne))||mo(this.options.staleTime,p(this,Ne))!==mo(r.staleTime,p(this,Ne)))&&Le(this,ot,Dc).call(this);let a=Le(this,ot,Vc).call(this);n&&(p(this,Ne)!==o||Rr(this.options.enabled,p(this,Ne))!==Rr(r.enabled,p(this,Ne))||a!==p(this,Rn))&&Le(this,ot,Lc).call(this,a);}getOptimisticResult(t){let r=p(this,Ir).getQueryCache().build(p(this,Ir),t),o=this.createResult(r,t);return Mh(this,o)&&(B(this,Sr,o),B(this,qi,this.options),B(this,ii,p(this,Ne).state)),o}getCurrentResult(){return p(this,Sr)}trackResult(t,r){return new Proxy(t,{get:(o,n)=>(this.trackProp(n),r?.(n),n==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&p(this,Ko).status==="pending"&&p(this,Ko).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,n))})}trackProp(t){p(this,Gi).add(t);}getCurrentQuery(){return p(this,Ne)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){let r=p(this,Ir).defaultQueryOptions(t),o=p(this,Ir).getQueryCache().build(p(this,Ir),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(t){return Le(this,ot,Hs).call(this,{...t,cancelRefetch:t.cancelRefetch??true}).then(()=>(this.updateResult(),p(this,Sr)))}createResult(t,r){let o=p(this,Ne),n=this.options,a=p(this,Sr),i=p(this,ii),s=p(this,qi),m=t!==o?t.state:p(this,Ns),{state:u}=t,h={...u},S=false,g;if(r._optimisticResults){let I=this.hasListeners(),A=!I&&cp(t,r),V=I&&dp(t,o,r,n);(A||V)&&(h={...h,...Fc(u.data,t.options)}),r._optimisticResults==="isRestoring"&&(h.fetchStatus="idle");}let{error:b,errorUpdatedAt:w,status:c}=h;g=h.data;let C=false;if(r.placeholderData!==void 0&&g===void 0&&c==="pending"){let I;a?.isPlaceholderData&&r.placeholderData===s?.placeholderData?(I=a.data,C=true):I=typeof r.placeholderData=="function"?r.placeholderData(p(this,Ki)?.state.data,p(this,Ki)):r.placeholderData,I!==void 0&&(c="success",g=Ms(a?.data,I,r),S=true);}if(r.select&&g!==void 0&&!C)if(a&&g===i?.data&&r.select===p(this,js))g=p(this,Qi);else try{B(this,js,r.select),g=r.select(g),g=Ms(a?.data,g,r),B(this,Qi,g),B(this,_n,null);}catch(I){B(this,_n,I);}p(this,_n)&&(b=p(this,_n),g=p(this,Qi),w=Date.now(),c="error");let y=h.fetchStatus==="fetching",f=c==="pending",d=c==="error",T=f&&y,_=g!==void 0,k={status:c,fetchStatus:h.fetchStatus,isPending:f,isSuccess:c==="success",isError:d,isInitialLoading:T,isLoading:T,data:g,dataUpdatedAt:h.dataUpdatedAt,error:b,errorUpdatedAt:w,failureCount:h.fetchFailureCount,failureReason:h.fetchFailureReason,errorUpdateCount:h.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:h.dataUpdateCount>m.dataUpdateCount||h.errorUpdateCount>m.errorUpdateCount,isFetching:y,isRefetching:y&&!f,isLoadingError:d&&!_,isPaused:h.fetchStatus==="paused",isPlaceholderData:S,isRefetchError:d&&_,isStale:Uc(t,r),refetch:this.refetch,promise:p(this,Ko),isEnabled:Rr(r.enabled,t)!==false};if(this.options.experimental_prefetchInRender){let I=k.data!==void 0,A=k.status==="error"&&!I,V=W=>{A?W.reject(k.error):I&&W.resolve(k.data);},F=()=>{let W=B(this,Ko,k.promise=zs());V(W);},P=p(this,Ko);switch(P.status){case "pending":t.queryHash===o.queryHash&&V(P);break;case "fulfilled":(A||k.data!==P.value)&&F();break;case "rejected":(!A||k.error!==P.reason)&&F();break}}return k}updateResult(){let t=p(this,Sr),r=this.createResult(p(this,Ne),this.options);if(B(this,ii,p(this,Ne).state),B(this,qi,this.options),p(this,ii).data!==void 0&&B(this,Ki,p(this,Ne)),Ga(r,t))return;B(this,Sr,r);let o=()=>{if(!t)return true;let{notifyOnChangeProps:n}=this.options,a=typeof n=="function"?n():n;if(a==="all"||!a&&!p(this,Gi).size)return true;let i=new Set(a??p(this,Gi));return this.options.throwOnError&&i.add("error"),Object.keys(p(this,Sr)).some(s=>{let l=s;return p(this,Sr)[l]!==t[l]&&i.has(l)})};Le(this,ot,pp).call(this,{listeners:o()});}onQueryUpdate(){this.updateResult(),this.hasListeners()&&Le(this,ot,Bc).call(this);}},Ir=new WeakMap,Ne=new WeakMap,Ns=new WeakMap,Sr=new WeakMap,ii=new WeakMap,qi=new WeakMap,Ko=new WeakMap,_n=new WeakMap,js=new WeakMap,Qi=new WeakMap,Ki=new WeakMap,si=new WeakMap,ai=new WeakMap,Rn=new WeakMap,Gi=new WeakMap,ot=new WeakSet,Hs=function(t){Le(this,ot,Ec).call(this);let r=p(this,Ne).fetch(this.options,t);return t?.throwOnError||(r=r.catch(Kt)),r},Dc=function(){Le(this,ot,Wc).call(this);let t=mo(this.options.staleTime,p(this,Ne));if(vo.isServer()||p(this,Sr).isStale||!As(t))return;let o=qa(p(this,Sr).dataUpdatedAt,t)+1;B(this,si,Io.setTimeout(()=>{p(this,Sr).isStale||this.updateResult();},o));},Vc=function(){return (typeof this.options.refetchInterval=="function"?this.options.refetchInterval(p(this,Ne)):this.options.refetchInterval)??false},Lc=function(t){Le(this,ot,Ac).call(this),B(this,Rn,t),!(vo.isServer()||Rr(this.options.enabled,p(this,Ne))===false||!As(p(this,Rn))||p(this,Rn)===0)&&B(this,ai,Io.setInterval(()=>{(this.options.refetchIntervalInBackground||Ui.isFocused())&&Le(this,ot,Hs).call(this);},p(this,Rn)));},Bc=function(){Le(this,ot,Dc).call(this),Le(this,ot,Lc).call(this,Le(this,ot,Vc).call(this));},Wc=function(){p(this,si)!==void 0&&(Io.clearTimeout(p(this,si)),B(this,si,void 0));},Ac=function(){p(this,ai)!==void 0&&(Io.clearInterval(p(this,ai)),B(this,ai,void 0));},Ec=function(){let t=p(this,Ir).getQueryCache().build(p(this,Ir),this.options);if(t===p(this,Ne))return;let r=p(this,Ne);B(this,Ne,t),B(this,Ns,t.state),this.hasListeners()&&(r?.removeObserver(this),t.addObserver(this));},pp=function(t){St.batch(()=>{t.listeners&&this.listeners.forEach(r=>{r(p(this,Sr));}),p(this,Ir).getQueryCache().notify({query:p(this,Ne),type:"observerResultsUpdated"});});},up);function Eh(e,t){return Rr(t.enabled,e)!==false&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===false)}function cp(e,t){return Eh(e,t)||e.state.data!==void 0&&Mc(e,t,t.refetchOnMount)}function Mc(e,t,r){if(Rr(t.enabled,e)!==false&&mo(t.staleTime,e)!=="static"){let o=typeof r=="function"?r(e):r;return o==="always"||o!==false&&Uc(e,t)}return false}function dp(e,t,r,o){return (e!==t||Rr(o.enabled,e)===false)&&(!r.suspense||e.state.status!=="error")&&Uc(e,r)}function Uc(e,t){return Rr(t.enabled,e)!==false&&e.isStaleByTime(mo(t.staleTime,e))}function Mh(e,t){return !Ga(e.getCurrentResult(),t)}function Hc(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 u=false,h=b=>{ep(b,()=>t.signal,()=>u=true);},S=Ya(t.options,t.fetchOptions),g=async(b,w,c)=>{if(u)return Promise.reject();if(w==null&&b.pages.length)return Promise.resolve(b);let y=(()=>{let _={client:t.client,queryKey:t.queryKey,pageParam:w,direction:c?"backward":"forward",meta:t.options.meta};return h(_),_})(),f=await S(y),{maxPages:d}=t.options,T=c?Xu:Zu;return {pages:T(b.pages,f,d),pageParams:T(b.pageParams,w,d)}};if(n&&a.length){let b=n==="backward",w=b?zh:mp,c={pages:a,pageParams:i},C=w(o,c);s=await g(c,C,b);}else {let b=e??a.length;do{let w=l===0?i[0]??o.initialPageParam:mp(o,s);if(l>0&&w==null)break;s=await g(s,w),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 mp(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 zh(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var $s,Po,hr,li,Oo,In,fp,hp=(fp=class extends el{constructor(t){super();Y(this,Oo);Y(this,$s);Y(this,Po);Y(this,hr);Y(this,li);B(this,$s,t.client),this.mutationId=t.mutationId,B(this,hr,t.mutationCache),B(this,Po,[]),this.state=t.state||Uh(),this.setOptions(t.options),this.scheduleGc();}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime);}get meta(){return this.options.meta}addObserver(t){p(this,Po).includes(t)||(p(this,Po).push(t),this.clearGcTimeout(),p(this,hr).notify({type:"observerAdded",mutation:this,observer:t}));}removeObserver(t){B(this,Po,p(this,Po).filter(r=>r!==t)),this.scheduleGc(),p(this,hr).notify({type:"observerRemoved",mutation:this,observer:t});}optionalRemove(){p(this,Po).length||(this.state.status==="pending"?this.scheduleGc():p(this,hr).remove(this));}continue(){return p(this,li)?.continue()??this.execute(this.state.variables)}async execute(t){let r=()=>{Le(this,Oo,In).call(this,{type:"continue"});},o={client:p(this,$s),meta:this.options.meta,mutationKey:this.options.mutationKey};B(this,li,Xa({fn:()=>this.options.mutationFn?this.options.mutationFn(t,o):Promise.reject(new Error("No mutationFn found")),onFail:(i,s)=>{Le(this,Oo,In).call(this,{type:"failed",failureCount:i,error:s});},onPause:()=>{Le(this,Oo,In).call(this,{type:"pause"});},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>p(this,hr).canRun(this)}));let n=this.state.status==="pending",a=!p(this,li).canStart();try{if(n)r();else {Le(this,Oo,In).call(this,{type:"pending",variables:t,isPaused:a}),p(this,hr).config.onMutate&&await p(this,hr).config.onMutate(t,this,o);let s=await this.options.onMutate?.(t,o);s!==this.state.context&&Le(this,Oo,In).call(this,{type:"pending",context:s,variables:t,isPaused:a});}let i=await p(this,li).start();return await p(this,hr).config.onSuccess?.(i,t,this.state.context,this,o),await this.options.onSuccess?.(i,t,this.state.context,o),await p(this,hr).config.onSettled?.(i,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(i,null,t,this.state.context,o),Le(this,Oo,In).call(this,{type:"success",data:i}),i}catch(i){try{await p(this,hr).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 p(this,hr).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 Le(this,Oo,In).call(this,{type:"error",error:i}),i}finally{p(this,hr).runNext(this);}}},$s=new WeakMap,Po=new WeakMap,hr=new WeakMap,li=new WeakMap,Oo=new WeakSet,In=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),St.batch(()=>{p(this,Po).forEach(o=>{o.onMutationUpdate(t);}),p(this,hr).notify({mutation:this,type:"updated",action:t});});},fp);function Uh(){return {context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:false,status:"idle",variables:void 0,submittedAt:0}}var Go,fo,qs,gp,yp=(gp=class extends _o{constructor(t={}){super();Y(this,Go);Y(this,fo);Y(this,qs);this.config=t,B(this,Go,new Set),B(this,fo,new Map),B(this,qs,0);}build(t,r,o){let n=new hp({client:t,mutationCache:this,mutationId:++bs(this,qs)._,options:t.defaultMutationOptions(r),state:o});return this.add(n),n}add(t){p(this,Go).add(t);let r=tl(t);if(typeof r=="string"){let o=p(this,fo).get(r);o?o.push(t):p(this,fo).set(r,[t]);}this.notify({type:"added",mutation:t});}remove(t){if(p(this,Go).delete(t)){let r=tl(t);if(typeof r=="string"){let o=p(this,fo).get(r);if(o)if(o.length>1){let n=o.indexOf(t);n!==-1&&o.splice(n,1);}else o[0]===t&&p(this,fo).delete(r);}}this.notify({type:"removed",mutation:t});}canRun(t){let r=tl(t);if(typeof r=="string"){let n=p(this,fo).get(r)?.find(a=>a.state.status==="pending");return !n||n===t}else return true}runNext(t){let r=tl(t);return typeof r=="string"?p(this,fo).get(r)?.find(n=>n!==t&&n.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){St.batch(()=>{p(this,Go).forEach(t=>{this.notify({type:"removed",mutation:t});}),p(this,Go).clear(),p(this,fo).clear();});}getAll(){return Array.from(p(this,Go))}find(t){let r={exact:true,...t};return this.getAll().find(o=>Ka(r,o))}findAll(t={}){return this.getAll().filter(r=>Ka(t,r))}notify(t){St.batch(()=>{this.listeners.forEach(r=>{r(t);});});}resumePausedMutations(){let t=this.getAll().filter(r=>r.state.isPaused);return St.batch(()=>Promise.all(t.map(r=>r.continue().catch(Kt))))}},Go=new WeakMap,fo=new WeakMap,qs=new WeakMap,gp);function tl(e){return e.options.scope?.id}var Fo,bp,Cp=(bp=class extends _o{constructor(t={}){super();Y(this,Fo);this.config=t,B(this,Fo,new Map);}build(t,r,o){let n=r.queryKey,a=r.queryHash??Es(n,r),i=this.get(a);return i||(i=new ap({client:t,queryKey:n,queryHash:a,options:t.defaultQueryOptions(r),state:o,defaultOptions:t.getQueryDefaults(n)}),this.add(i)),i}add(t){p(this,Fo).has(t.queryHash)||(p(this,Fo).set(t.queryHash,t),this.notify({type:"added",query:t}));}remove(t){let r=p(this,Fo).get(t.queryHash);r&&(t.destroy(),r===t&&p(this,Fo).delete(t.queryHash),this.notify({type:"removed",query:t}));}clear(){St.batch(()=>{this.getAll().forEach(t=>{this.remove(t);});});}get(t){return p(this,Fo).get(t)}getAll(){return [...p(this,Fo).values()]}find(t){let r={exact:true,...t};return this.getAll().find(o=>Qa(r,o))}findAll(t={}){let r=this.getAll();return Object.keys(t).length>0?r.filter(o=>Qa(t,o)):r}notify(t){St.batch(()=>{this.listeners.forEach(r=>{r(t);});});}onFocus(){St.batch(()=>{this.getAll().forEach(t=>{t.onFocus();});});}onOnline(){St.batch(()=>{this.getAll().forEach(t=>{t.onOnline();});});}},Fo=new WeakMap,bp);var Mt,vn,Pn,Yi,Ji,On,Zi,Xi,wp,Nc=(wp=class{constructor(e={}){Y(this,Mt);Y(this,vn);Y(this,Pn);Y(this,Yi);Y(this,Ji);Y(this,On);Y(this,Zi);Y(this,Xi);B(this,Mt,e.queryCache||new Cp),B(this,vn,e.mutationCache||new yp),B(this,Pn,e.defaultOptions||{}),B(this,Yi,new Map),B(this,Ji,new Map),B(this,On,0);}mount(){bs(this,On)._++,p(this,On)===1&&(B(this,Zi,Ui.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,Mt).onFocus());})),B(this,Xi,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),p(this,Mt).onOnline());})));}unmount(){var e,t;bs(this,On)._--,p(this,On)===0&&((e=p(this,Zi))==null||e.call(this),B(this,Zi,void 0),(t=p(this,Xi))==null||t.call(this),B(this,Xi,void 0));}isFetching(e){return p(this,Mt).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return p(this,vn).findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return p(this,Mt).get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),r=p(this,Mt).build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(mo(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return p(this,Mt).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=p(this,Mt).get(o.queryHash)?.state.data,i=Yu(t,a);if(i!==void 0)return p(this,Mt).build(this,o).setData(i,{...r,manual:true})}setQueriesData(e,t,r){return St.batch(()=>p(this,Mt).findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return p(this,Mt).get(t.queryHash)?.state}removeQueries(e){let t=p(this,Mt);St.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r);});});}resetQueries(e,t){let r=p(this,Mt);return St.batch(()=>(r.findAll(e).forEach(o=>{o.reset();}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){let r={revert:true,...t},o=St.batch(()=>p(this,Mt).findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(Kt).catch(Kt)}invalidateQueries(e,t={}){return St.batch(()=>(p(this,Mt).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=St.batch(()=>p(this,Mt).findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let a=n.fetch(void 0,r);return r.throwOnError||(a=a.catch(Kt)),n.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(o).then(Kt)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=false);let r=p(this,Mt).build(this,t);return r.isStaleByTime(mo(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Kt).catch(Kt)}fetchInfiniteQuery(e){return e.behavior=Hc(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Kt).catch(Kt)}ensureInfiniteQueryData(e){return e.behavior=Hc(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?p(this,vn).resumePausedMutations():Promise.resolve()}getQueryCache(){return p(this,Mt)}getMutationCache(){return p(this,vn)}getDefaultOptions(){return p(this,Pn)}setDefaultOptions(e){B(this,Pn,e);}setQueryDefaults(e,t){p(this,Yi).set(Zn(e),{queryKey:e,defaultOptions:t});}getQueryDefaults(e){let t=[...p(this,Yi).values()],r={};return t.forEach(o=>{ei(e,o.queryKey)&&Object.assign(r,o.defaultOptions);}),r}setMutationDefaults(e,t){p(this,Ji).set(Zn(e),{mutationKey:e,defaultOptions:t});}getMutationDefaults(e){let t=[...p(this,Ji).values()],r={};return t.forEach(o=>{ei(e,o.mutationKey)&&Object.assign(r,o.defaultOptions);}),r}defaultQueryOptions(e){if(e._defaulted)return e;let t={...p(this,Pn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:true};return t.queryHash||(t.queryHash=Es(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===Xn&&(t.enabled=false),t}defaultMutationOptions(e){return e?._defaulted?e:{...p(this,Pn).mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:true}}clear(){p(this,Mt).clear(),p(this,vn).clear();}},Mt=new WeakMap,vn=new WeakMap,Pn=new WeakMap,Yi=new WeakMap,Ji=new WeakMap,On=new WeakMap,Zi=new WeakMap,Xi=new WeakMap,wp);var jc=Fn.createContext(void 0),$c=e=>{let t=Fn.useContext(jc);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},qc=({client:e,children:t})=>(Fn.useEffect(()=>(e.mount(),()=>{e.unmount();}),[e]),jsx(jc.Provider,{value:e,children:t}));var Sp=Fn.createContext(false),kp=()=>Fn.useContext(Sp);Sp.Provider;function Nh(){let e=false;return {clearReset:()=>{e=false;},reset:()=>{e=true;},isReset:()=>e}}var jh=Fn.createContext(Nh()),Tp=()=>Fn.useContext(jh);var _p=(e,t,r)=>{let o=r?.state.error&&typeof e.throwOnError=="function"?Ja(e.throwOnError,[r.state.error,r]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||o)&&(t.isReset()||(e.retryOnMount=false));},Rp=e=>{Fn.useEffect(()=>{e.clearReset();},[e]);},Ip=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||Ja(r,[e.error,o]));var vp=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));}},Pp=(e,t)=>e.isLoading&&e.isFetching&&!t,Op=(e,t)=>e?.suspense&&t.isPending,Qc=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset();});function Fp(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=kp(),n=Tp(),a=$c(),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",vp(i),_p(i,n,s),Rp(n);let l=!a.getQueryCache().get(i.queryHash),[m]=Fn.useState(()=>new t(a,i)),u=m.getOptimisticResult(i),h=!o&&e.subscribed!==false;if(Fn.useSyncExternalStore(Fn.useCallback(S=>{let g=h?m.subscribe(St.batchCalls(S)):Kt;return m.updateResult(),g},[m,h]),()=>m.getCurrentResult(),()=>m.getCurrentResult()),Fn.useEffect(()=>{m.setOptions(i);},[i,m]),Op(i,u))throw Qc(i,m,n);if(Ip({result:u,errorResetBoundary:n,throwOnError:i.throwOnError,query:s,suspense:i.suspense}))throw u.error;return a.getDefaultOptions().queries?._experimental_afterQuery?.(i,u),i.experimental_prefetchInRender&&!vo.isServer()&&Pp(u,o)&&(l?Qc(i,m,n):s?.promise)?.catch(Kt).finally(()=>{m.updateResult();}),i.notifyOnChangeProps?u:m.trackResult(u)}function Yo(e,t){return Fp(e,zc)}var rs=new Map;function Dp({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 Vn({uri:e,width:t,height:r,borderRadius:o=0,borderWidth:n=0,borderColor:a="transparent",backgroundColor:i="transparent",style:s}){let{colors:l}=D(),[m,u]=useState(false),[h,S]=useState(false),[g,b]=useState(()=>{if(!e||!e.toLowerCase().endsWith(".svg"))return null;let T=rs.get(e);return T?{uri:e,xml:T}:null}),w=e?.toLowerCase().endsWith(".svg"),c=w&&e&&g?.uri===e?g.xml:null;useEffect(()=>{u(false),S(false);},[e]),useEffect(()=>{if(!w||!e)return;if(rs.has(e)){b({uri:e,xml:rs.get(e)});return}let T=false;return fetch(e).then(_=>{if(!_.ok)throw new Error(`HTTP ${_.status}`);return _.text()}).then(_=>{T||(rs.set(e,_),b({uri:e,xml:_}));}).catch(()=>{T||u(true);}),()=>{T=true;}},[e,w]);let C=l.card;if(!e)return jsx(View,{style:[{width:t,height:r,borderRadius:o,backgroundColor:C},s]});let y={width:t,height:r,borderRadius:o,borderWidth:n,borderColor:a,backgroundColor:i,overflow:"hidden",alignItems:"center",justifyContent:"center",...s},f=t-n*2,d=r-n*2;return m?jsx(View,{style:[y,{backgroundColor:i||C}]}):w?jsxs(View,{style:y,children:[!!!c&&jsx(Dp,{width:f,height:d,borderRadius:o,color:C}),c?jsx(SvgXml,{xml:c,width:f,height:d,onError:()=>u(true)}):jsx(SvgUri,{uri:e,width:f,height:d,onError:()=>u(true)})]}):jsxs(View,{style:y,children:[!h&&jsx(Dp,{width:f,height:d,borderRadius:o,color:C}),jsx(Image,{source:{uri:e,cache:"force-cache"},style:{width:f,height:d},resizeMode:"contain",onLoad:()=>S(true),onError:()=>u(true)})]})}function Yc(e){let t=[];for(let r of e)if(r)if(r.toLowerCase().endsWith(".svg")){if(rs.has(r))continue;t.push(fetch(r).then(o=>{if(!o.ok)throw new Error(`HTTP ${o.status}`);return o.text()}).then(o=>{rs.set(r,o);}).catch(()=>{}));}else t.push(Image.prefetch(r).then(()=>{}).catch(()=>{}));return Promise.all(t).then(()=>{})}function kr({title:e,subtitle:t,showBack:r=false,showClose:o=true,onBack:n,onClose:a,badge:i,showBalance:s=false,balanceAddress:l,balanceChainType:m,balanceChainId:u,balanceTokenAddress:h,publishableKey:S,projectName:g,leftIcon:b,onLeftAction:w}){let{colors:c,fonts:C,components:y}=D(),[f,d]=useState(null),[T,_]=useState(false),x=useState(()=>new Animated.Value(0))[0];useEffect(()=>{if(!T)return;let I=Animated.loop(Animated.sequence([Animated.timing(x,{toValue:1,duration:700,useNativeDriver:true}),Animated.timing(x,{toValue:0,duration:700,useNativeDriver:true})]));return I.start(),()=>I.stop()},[T,x]),useEffect(()=>{if(!s||!l||!m||!u||!h||!S){d(null),_(false);return}let I=false;return _(true),xa(l,m,u,h,S).then(A=>{if(I)return;let V=A.balance,F=null;V&&(V.amount_usd!=null&&V.amount_usd!==""?F=`$${V.amount_usd}`:F="$0.00"),d(F);}).catch(()=>{I||d(null);}).finally(()=>{I||_(false);}),()=>{I=true;}},[s,l,m,u,h,S]);let k=x.interpolate({inputRange:[0,1],outputRange:[.4,1]});return jsxs(View,{style:gr.header,children:[jsx(View,{style:gr.leftContainer,children:r&&n?jsx(TouchableOpacity,{onPress:n,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(ws,{size:20,color:y.header.buttonColor,strokeWidth:2})}):b&&w?jsx(TouchableOpacity,{onPress:w,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:b}):jsx(View,{style:gr.spacer})}),jsxs(View,{style:gr.titleContainer,children:[jsxs(View,{style:gr.titleRow,children:[jsx(Text,{style:[gr.title,{color:y.header.titleColor,fontFamily:C.medium}],children:e}),i&&i.count>0&&jsx(View,{style:[gr.titleBadge,{backgroundColor:c.card}],children:jsx(Text,{style:[gr.titleBadgeText,{color:c.foregroundMuted,fontFamily:C.regular}],children:i.count})})]}),t?jsx(Text,{style:[gr.balanceText,{color:c.foregroundMuted,fontFamily:C.regular}],children:t}):null,s&&(T?jsx(Animated.View,{style:[gr.balanceSkeleton,{backgroundColor:c.cardHover,opacity:k}]}):f!=null?jsxs(Text,{style:[gr.balanceText,{color:c.foregroundMuted,fontFamily:C.regular}],children:[g?`${g} `:"","Balance: ",f]}):null)]}),jsx(View,{style:gr.rightContainer,children:o?jsx(TouchableOpacity,{onPress:a,style:[gr.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:y.header.buttonColor,strokeWidth:2})}):jsx(View,{style:gr.spacer})})]})}var gr=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 Gt({children:e,style:t,contentStyle:r,onPress:o,activeOpacity:n=.7,cardTokens:a}){let{components:i}=D(),s=a??i.card,l=s.backShadowColor!=="transparent",m={backgroundColor:s.backgroundColor,borderRadius:s.borderRadius,borderWidth:s.borderWidth,borderColor:s.borderColor},u=[Wp.wrapper,t,l&&{marginBottom:s.backShadowSpacing}],h=[m,r];return jsxs(View,{style:u,children:[l&&jsx(View,{style:[Wp.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:h,children:e}):jsx(View,{style:h,children:e})]})}var Wp=StyleSheet.create({wrapper:{position:"relative"},backShadow:{position:"absolute"}});function Ks({onPress:e,title:t,subtitle:r,featuredTokens:o}){let{fonts:n,components:a}=D(),i=a.depositMenu.card,s=o?[...o].sort((l,m)=>l.position-m.position):[];return jsxs(Gt,{cardTokens:i,onPress:e,style:Do.wrapper,contentStyle:Do.container,children:[jsxs(View,{style:Do.leftContent,children:[jsx(View,{style:[Do.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(Kl,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Do.textContainer,children:[jsx(Text,{style:[Do.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Do.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Do.rightContent,children:jsx(View,{style:Do.networkIcons,children:s.map((l,m)=>{let u=l.icon_urls.find(h=>h.format==="png")?.url||l.icon_urls.find(h=>h.format==="svg")?.url;return jsx(View,{style:[Do.networkIconWrapper,{marginLeft:m===0?0:-6,zIndex:s.length-m}],children:jsx(Vn,{uri:J(u),width:20,height:20})},l.name)})})})]})}var Do=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 Ys({onPress:e,title:t,subtitle:r,paymentNetworks:o}){let{fonts:n,components:a}=D(),i=a.depositMenu.card;return jsxs(Gt,{cardTokens:i,onPress:e,style:Jo.wrapper,contentStyle:Jo.container,children:[jsxs(View,{style:Jo.leftContent,children:[jsx(View,{style:[Jo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:jsx(_i,{size:20,color:i.iconColor,strokeWidth:2})}),jsxs(View,{style:Jo.textContainer,children:[jsx(Text,{style:[Jo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Jo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]}),jsx(View,{style:Jo.rightContent,children:jsx(View,{style:Jo.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(Vn,{uri:J(l),width:32,height:20,borderRadius:4},s.name)})})})]})}var Jo=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 Js({onPress:e,title:t,subtitle:r,badge:o}){let{fonts:n,components:a}=D(),i=a.depositMenu.card;return jsx(Gt,{cardTokens:i,onPress:e,style:Zo.wrapper,contentStyle:Zo.container,children:jsxs(View,{style:Zo.leftContent,children:[jsxs(View,{style:[Zo.iconContainer,{borderRadius:i.iconContainerBorderRadius}],children:[jsx(bo,{size:20,color:i.iconColor,strokeWidth:2}),o!==void 0&&o>0&&jsx(View,{style:[Zo.badge,{backgroundColor:i.iconColor,borderRadius:a.badge.borderRadius}],children:jsx(Text,{style:[Zo.badgeText,{fontFamily:n.semibold}],children:o>99?"99+":o})})]}),jsxs(View,{style:Zo.textContainer,children:[jsx(Text,{style:[Zo.title,{color:i.titleColor,fontFamily:n.regular}],children:t}),jsx(Text,{style:[Zo.subtitle,{color:i.subtitleColor,fontFamily:n.regular}],children:r})]})]})})}var Zo=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 Xs({onPress:e,title:t,subtitle:r}){let{fonts:o,components:n}=D(),a=n.depositMenu.card;return jsxs(Gt,{cardTokens:a,onPress:e,style:Vo.wrapper,contentStyle:Vo.container,children:[jsxs(View,{style:Vo.leftContent,children:[jsx(View,{style:[Vo.iconContainer,{borderRadius:a.iconContainerBorderRadius}],children:jsx(ga,{size:20,color:a.iconColor,strokeWidth:2})}),jsxs(View,{style:Vo.textContainer,children:[jsx(Text,{style:[Vo.title,{color:a.titleColor,fontFamily:o.regular}],children:t}),jsx(Text,{style:[Vo.subtitle,{color:a.subtitleColor,fontFamily:o.regular}],children:r})]})]}),jsx(View,{style:Vo.rightContent,children:jsx(View,{style:Vo.badge,children:jsx(Text,{style:[Vo.badgeText,{fontFamily:o.regular}],children:"Stripe"})})})]})}var Vo=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 zp=1e4,Up=2500,Hp=3e3,Np=6e4;function ea(e){let{depositConfirmationMode:t,depositAddress:r,chain:o,externalUserId:n,publishableKey:a,modalOpenedAt:i,depositWalletId:s,depositExecutions:l,trackedExecutions:m,setDepositExecutions:u,setTrackedExecutions:h,setLatestExecution:S,setShowStatusSheet:g,onDepositSuccess:b,onExecutionsChange:w,onDepositError:c}=e,[C,y]=useState(false),[f,d]=useState(false);return useEffect(()=>{if(t!=="auto_ui"&&t!=="auto_silent"||!r)return;y(false),t==="auto_ui"&&d(false);let _=setTimeout(()=>{y(true),t==="auto_ui"&&d(true);},zp);return ()=>clearTimeout(_)},[t,r,o]),useEffect(()=>{if(!n||!i)return;let _=new Date(i.getTime()-Np),x=setInterval(async()=>{try{let A=[...(await No(n,a)).data??[]].sort((F,P)=>{let W=F.created_at?new Date(F.created_at).getTime():0;return (P.created_at?new Date(P.created_at).getTime():0)-W}),V=null;for(let F of A){let P=F.created_at?new Date(F.created_at):null;if(!P||P<=_)continue;let W=m.get(F.id);if(!W){V=F;break}if(["pending","waiting","delayed"].includes(W)&&F.status==="succeeded"){V=F;break}}if(V){let F=V;u(P=>{let W=P.findIndex($=>$.id===F.id);if(W>=0){let $=[...P];return $[W]=F,$}return [...P,F]}),h(P=>{let W=new Map(P);return W.set(F.id,F.status),W}),S(F),g(!0),F.status==="succeeded"&&b?.({message:"Deposit completed successfully",executionId:F.id}),w?.([...l,F]);}}catch(k){c?.({message:"Failed to check deposit status",error:k});}},Up);return ()=>clearInterval(x)},[n,a,i,m,l,w,b,c]),useEffect(()=>{if(!C||!s)return;let _=async()=>{try{await wa(s,a);}catch{}};_();let x=setInterval(_,Hp);return ()=>clearInterval(x)},[C,s,a]),{pollingEnabled:C,showWaitingUi:f,handleIveDeposited:()=>{y(true),d(true);}}}function ss({value:e,size:t=180,logoUri:r,logoSize:o=40,logoBackgroundColor:n}){let{colors:a,isDark:i}=D(),s=i?"#1a1a1a":"#ffffff",l=i?"#ffffff":"#000000",m=n||s;return jsxs(View,{style:[$p.container,{width:t,height:t}],children:[jsx(og,{value:e||"placeholder",size:t,backgroundColor:s,color:l,ecl:"H",quietZone:4}),r&&jsx(View,{style:[$p.logoContainer,{width:o+12,height:o+12,backgroundColor:m,borderRadius:(o+12)/2}],children:jsx(Vn,{uri:r,width:o,height:o,borderRadius:o/2})})]})}var $p=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function Kp(e){let t=e.split("/"),r=t[t.length-1];return r&&r.length>10?`${r.slice(0,6)}...${r.slice(-3)}`:r||""}function ag(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 as({visible:e,status:t,tokenIconUrl:r,explorerUrl:o,completionExplorerUrl:n,date:a,amountUsd:i,onClose:s,borderTopLeftRadius:l,borderTopRightRadius:m}){let{colors:u,fonts:h,components:S}=D(),[g,b]=useState(false),w=t==="pending"||t==="waiting"||t==="delayed",c=t==="succeeded",C=()=>{o&&Linking.openURL(o);},y=()=>{n&&Linking.openURL(n);};return jsx(ct,{visible:e,onClose:s,closeOnBackdropPress:true,showHandle:false,borderTopLeftRadius:l,borderTopRightRadius:m,children:jsxs(View,{style:Ot.container,children:[jsx(TouchableOpacity,{style:Ot.closeButton,onPress:s,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:S.header.buttonColor,strokeWidth:2})}),jsx(View,{style:Ot.iconContainer,children:w?jsx(ht,{size:80,strokeWidth:4,iconSize:68,children:r?jsx(Image,{source:{uri:J(r)},style:Ot.tokenIconFill}):jsx(View,{style:[Ot.tokenIconFill,{backgroundColor:u.cardHover}]})}):jsxs(Fragment,{children:[r?jsx(Image,{source:{uri:J(r)},style:Ot.tokenIconLarge}):jsx(View,{style:[Ot.tokenIconLarge,{backgroundColor:u.cardHover}]}),jsx(View,{style:[Ot.statusBadge,{backgroundColor:S.container.iconBackgroundColor}],children:jsx(qe,{size:16,color:S.container.iconColor,strokeWidth:3})})]})}),jsx(Text,{style:[Ot.title,{color:S.container.titleColor,fontFamily:h.semibold}],children:w?"Deposit Processing":"Deposit Complete"}),i!==void 0&&jsxs(Text,{style:[Ot.amount,{color:S.container.titleColor,fontFamily:h.bold}],children:["$",i.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),a&&jsx(Text,{style:[Ot.date,{color:S.container.subtitleColor,fontFamily:h.regular}],children:ag(a)}),jsx(Text,{style:[Ot.subtitle,{color:S.container.subtitleColor,fontFamily:h.regular}],children:w?"This usually takes less than a minute.":"Your account has been credited successfully!"}),c&&(o||n)&&jsxs(View,{style:Ot.detailsSection,children:[jsx(View,{style:[Ot.divider,{backgroundColor:u.border}]}),jsxs(TouchableOpacity,{style:Ot.detailsToggle,onPress:()=>b(!g),children:[jsx(Text,{style:[Ot.detailsToggleText,{color:S.container.actionTitle,fontFamily:h.medium}],children:g?"See less":"See more details"}),g?jsx(wo,{size:18,color:S.container.actionColor,strokeWidth:2}):jsx(Pt,{size:18,color:S.container.actionColor,strokeWidth:2})]}),g&&jsxs(View,{style:Ot.txButtonsContainer,children:[o&&jsxs(TouchableOpacity,{style:[Ot.txButton,{backgroundColor:S.card.backgroundColor,borderColor:u.border}],onPress:C,children:[jsx(Text,{style:[Ot.txLabel,{color:S.card.titleColor,fontFamily:h.medium}],children:"Deposit tx"}),jsx(Text,{style:[Ot.txHash,{color:S.card.subtitleColor,fontFamily:h.regular}],children:Kp(o)}),jsx(Co,{size:16,color:S.card.actionColor,strokeWidth:2})]}),n&&jsxs(TouchableOpacity,{style:[Ot.txButton,{backgroundColor:S.card.backgroundColor,borderColor:u.border}],onPress:y,children:[jsx(Text,{style:[Ot.txLabel,{color:S.card.titleColor,fontFamily:h.medium}],children:"Completion tx"}),jsx(Text,{style:[Ot.txHash,{color:S.card.subtitleColor,fontFamily:h.regular}],children:Kp(n)}),jsx(Co,{size:16,color:S.card.actionColor,strokeWidth:2})]})]})]})]})})}var Ot=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 ll({depositConfirmationMode:e,depositAddress:t,showWaitingUi:r,latestExecution:o,onIveDeposited:n}){let{colors:a,fonts:i,components:s}=D();return jsxs(Fragment,{children:[e==="manual"&&t&&!r&&jsx(TouchableOpacity,{onPress:n,activeOpacity:.8,style:[ui.iveDepositedButton,{backgroundColor:a.primary,borderRadius:s.button.borderRadius,borderWidth:s.button.borderWidth,borderColor:s.button.borderColor}],children:jsx(Text,{style:[ui.iveDepositedButtonText,{color:a.primaryForeground??"#FFF",fontFamily:i.semibold}],children:"I've made the deposit"})}),r&&!o&&jsxs(View,{style:[ui.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:[ui.detailIcon,{backgroundColor:s.card.iconBackgroundColor,borderRadius:s.card.iconContainerBorderRadius}],children:jsx(Gl,{size:14,color:s.card.iconColor,strokeWidth:2})}),jsxs(View,{style:ui.processingCardText,children:[jsx(Text,{style:[ui.processingCardTitle,{color:s.card.titleColor,fontFamily:i.semibold}],children:"Processing deposit transactions."}),jsx(Text,{style:[ui.processingCardSubtitle,{color:s.card.subtitleColor,fontFamily:i.regular}],children:"We're checking if your deposit has landed."})]})]})]})}var ui=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 ta=(e,t)=>`${t}:${e}`,gg=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function dl({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:u="auto_ui",onExecutionsChange:h,onDepositSuccess:S,onDepositError:g,borderTopLeftRadius:b,borderTopRightRadius:w,sheetBorderRadius:c}){let{colors:C,fonts:y,components:f}=D(),d=s&&l?`${s}:${l}`:"solana:mainnet",[T,_]=useState("USDC"),[x,k]=useState(d),[I,A]=useState([]),[V,F]=useState(true),[P,W]=useState([]),[$,fe]=useState(true),[Ke,Fe]=useState(false),[G,Se]=useState(false),[he,Ie]=useState(false),[Ge,ke]=useState(false),[te,Te]=useState([]),[st,We]=useState(new Map),[Ye]=useState(()=>new Date),[Ae,Ee]=useState(null),[Me,pe]=useState(false),[X,be]=useState(null),[pt,z]=useState(false),E=new Map;P.forEach(j=>{j.chains.forEach(re=>{let _e=`${re.chain_type}:${re.chain_id}`;E.has(_e)||E.set(_e,re);});});let se=Array.from(E.values()),oe=gg(x),xt=se.find(j=>j.chain_type===oe.chainType&&j.chain_id===oe.chainId)?.chain_type||"ethereum",ce=Ho(I,xt),ae=ce?.address||"",ze=useRef(false);useEffect(()=>{async function j(){try{fe(!0),Ee(null);let _e=await Nn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(W(_e.data),_e.data.length>0&&!ze.current){ze.current=!0;let ue,ne;if(s&&l)if(m)for(let O of _e.data){let ft=O.chains.find(De=>De.chain_type===s&&De.chain_id===l&&De.token_address.toLowerCase()===m.toLowerCase());if(ft){ue=O,ne=ft;break}}else for(let O of _e.data){let ft=O.chains.find(De=>De.chain_type===s&&De.chain_id===l);if(ft){ue=O,ne=ft;break}}if(!ue&&a)for(let O of _e.data){let ft=O.chains.find(De=>De.token_address.toLowerCase()===a.toLowerCase());if(ft){ue=O,ne=ft;break}}ue||(ue=_e.data.find(O=>O.symbol==="USDC"),ue&&ue.chains.length>0&&(ne=ue.chains[0])),ue||(ue=_e.data.find(O=>O.symbol==="USDT"),ue&&ue.chains.length>0&&(ne=ue.chains[0])),ue||(ue=_e.data[0],ue.chains.length>0&&(ne=ue.chains[0])),ue&&_(ue.symbol),ne&&k(ta(ne.chain_id,ne.chain_type));}}catch(re){console.error("Error fetching supported tokens:",re),Ee("Failed to load supported tokens"),g?.({message:"Failed to load supported tokens",error:re});}finally{fe(false);}}j();},[t,g,s,l,m,a,n,o]),useEffect(()=>{async function j(){try{F(!0),Ee(null);let re=await Uo({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);A(re.data);}catch(re){console.error("Error fetching wallets:",re),Ee("Failed to load wallets"),g?.({message:"Failed to load wallets",error:re});}finally{F(false);}}j();},[e,r,o,n,a,t,g]);let Yt=ce?.id??"",{showWaitingUi:mt,handleIveDeposited:de}=ea({depositConfirmationMode:u,depositAddress:ae,chain:x,externalUserId:e,publishableKey:t,modalOpenedAt:Ye,depositWalletId:Yt,depositExecutions:te,trackedExecutions:st,setDepositExecutions:Te,setTrackedExecutions:We,setLatestExecution:be,setShowStatusSheet:pe,onDepositSuccess:S,onExecutionsChange:h,onDepositError:g});useEffect(()=>{if(!P.length)return;let j=P.find(_e=>_e.symbol===T);if(!j||j.chains.length===0)return;if(!j.chains.some(_e=>ta(_e.chain_id,_e.chain_type)===x)){let _e=j.chains[0];k(ta(_e.chain_id,_e.chain_type));}},[T,P,x]);let et=P.find(j=>j.symbol===T),xr=et?.chains||[],_t=xr.find(j=>ta(j.chain_id,j.chain_type)===x),io=async()=>{if(ae)try{Clipboard.setString(ae),Fe(!0),setTimeout(()=>Fe(!1),2e3);}catch(j){console.error("Failed to copy:",j);}},Or=_t?.estimated_price_impact_percent??0,ir=_t?.max_slippage_percent??.25,$t=_t?.minimum_deposit_amount_usd??3;if($)return jsxs(View,{style:L.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:C.primary}),jsx(Text,{style:[L.loadingText,{color:C.foregroundMuted,fontFamily:y.regular}],children:"Loading currencies..."})]});if(Ae&&P.length===0)return jsxs(View,{style:L.errorContainer,children:[jsx(Text,{style:[L.errorText,{color:C.error,fontFamily:y.regular}],children:Ae}),jsx(Text,{style:[L.errorHint,{color:C.foregroundMuted,fontFamily:y.regular}],children:"Please check your network connection and try again."})]});let xe=()=>jsxs(ct,{visible:he,onClose:()=>Ie(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c?.tokenSelector?.borderTopLeftRadius??b,borderTopRightRadius:c?.tokenSelector?.borderTopRightRadius??w,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:C.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:f.header.titleColor,fontFamily:y.medium}],children:"Select Token"}),jsx(TouchableOpacity$1,{onPress:()=>Ie(false),style:L.sheetCloseButton,children:jsx(tt,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsx(BottomSheetScrollView,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:P.map(j=>jsxs(TouchableOpacity$1,{onPress:()=>{_(j.symbol),Ie(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:T===j.symbol?f.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:J(ge(j,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:f.card.titleColor,fontFamily:y.medium}],children:j.symbol}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:f.card.subtitleColor,fontFamily:y.regular}],children:[j.chains.length," network",j.chains.length!==1?"s":""," available"]})]}),T===j.symbol&&jsx(qe,{size:20,color:C.primary,strokeWidth:2})]},j.symbol))})]}),at=()=>jsxs(ct,{visible:Ge,onClose:()=>ke(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:c?.chainSelector?.borderTopLeftRadius??b,borderTopRightRadius:c?.chainSelector?.borderTopRightRadius??w,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:C.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:f.header.titleColor,fontFamily:y.medium}],children:"Select Network"}),jsx(TouchableOpacity$1,{onPress:()=>ke(false),style:L.sheetCloseButton,children:jsx(tt,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsx(BottomSheetScrollView,{style:L.sheetList,contentContainerStyle:L.sheetListContent,showsVerticalScrollIndicator:false,children:xr.map(j=>{let re=ta(j.chain_id,j.chain_type),_e=x===re;return jsxs(TouchableOpacity$1,{onPress:()=>{k(re),ke(false);},activeOpacity:.7,style:[L.sheetItem,{backgroundColor:_e?f.card.backgroundColor:"transparent"}],children:[jsx(Image,{source:{uri:J(ge(j,"png"))},style:L.sheetItemIcon}),jsxs(View,{style:L.sheetItemText,children:[jsx(Text,{style:[L.sheetItemTitle,{color:f.card.titleColor,fontFamily:y.medium}],children:j.chain_name}),jsxs(Text,{style:[L.sheetItemSubtitle,{color:f.card.subtitleColor,fontFamily:y.regular}],children:["Min deposit: $",j.minimum_deposit_amount_usd]})]}),_e&&jsx(qe,{size:20,color:C.primary,strokeWidth:2})]},re)})})]});return jsxs(View,{style:L.container,children:[jsxs(View,{style:L.selectorSection,children:[jsx(Text,{style:[L.selectorLabel,{color:f.card.labelColor,fontFamily:y.regular}],children:"Token"}),jsxs(TouchableOpacity$1,{onPress:()=>Ie(true),style:[L.selector,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[et&&jsx(Image,{source:{uri:J(ge(et,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:f.card.titleColor,fontFamily:y.medium}],children:T}),jsx(Pt,{size:16,color:f.card.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:L.selectorSection,children:[jsxs(Text,{style:[L.selectorLabel,{color:f.card.labelColor,fontFamily:y.regular}],children:["Network"," ",jsxs(Text,{style:[L.minDeposit,{fontFamily:y.regular}],children:["($",$t," min)"]})]}),jsxs(TouchableOpacity$1,{onPress:()=>ke(true),style:[L.selector,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[_t&&jsx(Image,{source:{uri:J(ge(_t,"png"))},style:L.selectorIcon}),jsx(Text,{style:[L.selectorText,{color:f.card.titleColor,fontFamily:y.medium}],numberOfLines:1,children:_t?.chain_name||"Select network"}),jsx(Pt,{size:16,color:f.card.actionColor,strokeWidth:2})]})]}),jsx(View,{style:L.qrContainer,children:jsx(View,{style:[L.qrWrapper,{backgroundColor:C.background,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth>0?f.card.borderWidth:1,borderColor:f.card.borderColor}],children:V?jsxs(View,{style:L.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:C.primary}),jsx(Text,{style:[L.loadingText,{color:C.foregroundMuted,fontFamily:y.regular}],children:"Loading..."})]}):ae?jsx(ss,{value:ae,size:160,logoUri:J(ge(_t,"png")||Ht("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:L.qrLoading,children:jsx(Text,{style:[L.errorText,{color:C.error,fontFamily:y.regular}],children:"No address available"})})})}),jsxs(View,{style:L.addressSection,children:[jsxs(View,{style:L.addressHeader,children:[jsx(Text,{style:[L.addressLabel,{color:f.card.labelColor,fontFamily:y.medium}],children:"Deposit Address"}),Ke&&jsxs(View,{style:L.copiedIndicator,children:[jsx(qe,{size:14,color:C.success,strokeWidth:2}),jsx(Text,{style:[L.copiedText,{color:C.success,fontFamily:y.regular}],children:"Copied"})]})]}),jsxs(Gt,{cardTokens:f.transferCrypto.depositAddress.card,onPress:!V&&ae?io:void 0,contentStyle:L.addressBox,children:[jsx(Text,{style:[L.addressText,{color:f.card.titleColor,fontFamily:y.regular}],numberOfLines:2,children:V?"Loading...":ae||"No address available"}),jsx(View,{style:L.addressCopyIcon,children:jsx(Hn,{size:16,color:f.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[L.detailsCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Se(!G),style:L.detailsHeader,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(bo,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.detailsLabel,{color:f.card.titleColor,fontFamily:y.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:L.chevronContainer,children:G?jsx(wo,{size:16,color:f.card.actionColor,strokeWidth:2}):jsx(Pt,{size:16,color:f.card.actionColor,strokeWidth:2})})]}),G&&jsxs(View,{style:L.detailsContent,children:[jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:f.card.titleColor,fontFamily:y.regular}],children:["Price impact: ",Or.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>z(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ii,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:f.card.titleColor,fontFamily:y.regular}],children:["Slippage: Auto \u2022 ",ir.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>z(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ii,{size:14,color:f.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:L.detailsRow,children:[jsx(View,{style:[L.detailIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fa,{size:12,color:f.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[L.detailsLabel,{color:f.card.titleColor,fontFamily:y.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(ll,{depositConfirmationMode:u,depositAddress:ae,showWaitingUi:mt,latestExecution:X,onIveDeposited:de}),jsx(TouchableOpacity$1,{style:L.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[L.termsText,{color:C.primary,fontFamily:y.regular}],children:"Terms apply"})}),xe(),at(),jsxs(ct,{visible:pt,onClose:()=>z(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:c?.infoSheet?.borderTopLeftRadius??b,borderTopRightRadius:c?.infoSheet?.borderTopRightRadius??w,children:[jsxs(View,{style:[L.sheetHeader,{borderBottomColor:C.border}],children:[jsx(View,{style:L.sheetHeaderSpacer}),jsx(Text,{style:[L.sheetTitle,{color:f.header.titleColor,fontFamily:y.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>z(false),style:L.sheetCloseButton,children:jsx(tt,{size:20,color:f.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:L.infoSheetContent,children:[jsxs(View,{style:[L.infoCard,{backgroundColor:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(mn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:f.card.titleColor,fontFamily:y.medium}],children:"Price Impact"}),jsxs(Text,{style:[L.infoCardValue,{color:f.card.titleColor,fontFamily:y.medium}],children:[Or.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:f.card.descriptionColor,fontFamily:y.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:f.card.backgroundColor,borderRadius:f.card.borderRadius,borderWidth:f.card.borderWidth,borderColor:f.card.borderColor}],children:[jsxs(View,{style:L.infoCardHeader,children:[jsx(View,{style:[L.infoCardIcon,{backgroundColor:f.card.iconBackgroundColor,borderRadius:f.card.iconContainerBorderRadius}],children:jsx(fn,{size:16,color:f.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[L.infoCardTitle,{color:f.card.titleColor,fontFamily:y.medium}],children:"Max Slippage"}),jsxs(Text,{style:[L.infoCardValue,{color:f.card.titleColor,fontFamily:y.medium}],children:[ir.toFixed(2),"%"]})]}),jsx(Text,{style:[L.infoCardDescription,{color:f.card.descriptionColor,fontFamily:y.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."})]})]})]}),X&&jsx(as,{visible:Me,status:X.status,tokenIconUrl:X.destination_token_metadata?.icon_urls?.find(j=>j.format==="png")?.url||X.destination_token_metadata?.icon_url||ge(et,"png"),explorerUrl:X.explorer_url,completionExplorerUrl:X.destination_explorer_url,date:X.created_at?new Date(X.created_at):void 0,amountUsd:X.source_amount_usd?parseFloat(X.source_amount_usd):void 0,onClose:()=>pe(false),borderTopLeftRadius:c?.depositStatus?.borderTopLeftRadius??b,borderTopRightRadius:c?.depositStatus?.borderTopRightRadius??w})]})}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 ul({currency:e,isSelected:t,onSelect:r}){let{colors:o,fonts:n,components:a}=D();return jsxs(TouchableOpacity$1,{onPress:()=>r(e.currency_code),activeOpacity:.7,style:[pi.container,{backgroundColor:a.card.backgroundColor,borderRadius:a.list.rowBorderRadius,borderWidth:a.card.borderWidth,borderColor:a.card.borderColor}],children:[jsxs(View,{style:pi.leftContent,children:[jsx(View,{style:[pi.iconContainer,{backgroundColor:o.background}],children:jsx(Image,{source:{uri:J(ge(e,"png"))},style:pi.icon})}),jsxs(View,{style:pi.textContainer,children:[jsx(Text,{style:[pi.name,{color:a.card.titleColor,fontFamily:n.medium}],children:e.name}),jsx(Text,{style:[pi.code,{color:a.card.subtitleColor,fontFamily:n.regular}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(qe,{size:16,color:o.primary,strokeWidth:2})]})}var pi=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 oa({title:e,currencies:t,selectedCurrency:r,onSelect:o}){let{fonts:n,components:a}=D();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:Zp.headerContainer,children:jsx(Text,{style:[Zp.title,{color:a.list.titleSectionColor,fontFamily:n.medium}],children:e})}),t.map(i=>jsx(ul,{currency:i,isSelected:r.toLowerCase()===i.currency_code.toLowerCase(),onSelect:o},i.currency_code))]})}var Zp=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function ml({open:e,onOpenChange:t,currencies:r,preferredCurrencyCodes:o,selectedCurrency:n,onSelectCurrency:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:u}=D(),[h,S]=useState(""),g=o.map(d=>r.find(T=>T.currency_code.toLowerCase()===d.toLowerCase())).filter(d=>d!==void 0),b=r.filter(d=>!o.includes(d.currency_code.toLowerCase())),w=d=>{if(!h)return d;let T=h.toLowerCase();return d.filter(_=>_.name.toLowerCase().includes(T)||_.currency_code.toLowerCase().includes(T))},c=w(g),C=w(b),y=d=>{a(d),t(false),S("");},f=()=>{t(false),S("");};return jsxs(ct,{visible:e,onClose:f,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsx(kr,{title:"Currency",showBack:false,onClose:f}),jsx(View,{style:mi.searchContainer,children:jsx(TextInput,{style:[mi.searchInput,{backgroundColor:u.search.backgroundColor,color:u.search.inputColor,fontFamily:m.regular,borderRadius:u.input.borderRadius,borderWidth:u.input.borderWidth,borderColor:u.input.borderColor}],value:h,onChangeText:S,placeholder:"Search",placeholderTextColor:u.search.placeholderColor})}),jsx(BottomSheetScrollView,{style:mi.listContainer,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",children:jsxs(View,{style:mi.listContent,children:[jsx(oa,{title:"Popular currencies",currencies:c,selectedCurrency:n,onSelect:y}),c.length>0&&C.length>0&&jsx(View,{style:mi.sectionSpacer}),jsx(oa,{title:"All currencies",currencies:C,selectedCurrency:n,onSelect:y}),c.length===0&&C.length===0&&jsx(View,{style:mi.noResultsContainer,children:jsx(Text,{style:[mi.noResultsText,{color:u.container.subtitleColor,fontFamily:m.regular}],children:"No currencies found"})})]})})]})}var mi=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 yd(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 gl({externalUserId:e,publishableKey:t,view:r,onViewChange:o,destinationTokenSymbol:n,recipientAddress:a,destinationChainType:i,destinationChainId:s,destinationTokenAddress:l,onDepositSuccess:m,onDepositError:u,borderTopLeftRadius:h,borderTopRightRadius:S,sheetBorderRadius:g}){let{colors:b,fonts:w,components:c}=D(),[C,y]=useState(""),[f,d]=useState("usd"),[T,_]=useState(false),[x,k]=useState(false),[I,A]=useState([]),[V,F]=useState(false),[P,W]=useState(null),[$,fe]=useState(null),[Ke,Fe]=useState("amount"),[G,Se]=useState(null),[he,Ie]=useState(true),[Ge,ke]=useState(null),[te,Te]=useState(false),st=useRef(null),We=useRef(false);useEffect(()=>{st.current=G;},[G]),useEffect(()=>{We.current=te;},[te]);let[Ye,Ae]=useState([]),[Ee,Me]=useState(true),[pe,X]=useState(60),[be,pt]=useState([]),[z,E]=useState([]),[se,oe]=useState(null),[ve,xt]=useState(null),[ce,ae]=useState(true),[ze,Yt]=useState(null),[mt,de]=useState(false),[et,xr]=useState(null),[_t,io]=useState(false),[Or,ir]=useState(false),[$t,xe]=useState(false),[at,j]=useState(null),re=r??Ke,_e=useRef(null),ue=be.find(q=>q.currency_code.toLowerCase()===f.toLowerCase()),ne=useCallback(q=>{Fe(q),q==="quotes"?o?.(q,I.length):o?.(q);},[I.length,o]);useEffect(()=>{async function q(){try{let ie=await Is();xt(ie);}catch(ie){console.error("Error fetching user IP:",ie);}finally{ae(false);}}q();},[]),useEffect(()=>{async function q(){try{let ie=await Uo({external_user_id:e,recipient_address:a,destination_chain_type:i,destination_chain_id:s,destination_token_address:l},t);Ae(ie.data);}catch(ie){console.error("Error fetching wallets:",ie),W("Failed to load wallet addresses");}finally{Me(false);}}q();},[e,a,i,s,l,t]);let O=n||se?.symbol.toUpperCase()||"USDC",ft=Fi(se?.icon_urls,"png")||se?.icon_url,De=Fi(se?.chain_icon_urls,"png")||se?.chain_icon_url;useEffect(()=>{async function q(){try{let ie=await rc(t);pt(ie.data),E(ie.preferred||[]);}catch(ie){console.error("Error fetching fiat currencies:",ie);}}q();},[t]),useEffect(()=>{if(T||be.length===0||!ve?.alpha2)return;let q=ve.alpha2.toUpperCase(),ie=be.find(wt=>wt.country_codes.includes(q));if(ie)d(ie.currency_code.toLowerCase()),!C&&!x&&y(String(ie.default_amount??100));else if(!C&&!x){let wt=be.find(Fr=>Fr.currency_code.toLowerCase()==="usd");wt&&y(String(wt.default_amount??100));}},[be,ve,T,C,x]),useEffect(()=>{if(be.length!==0){if(_e.current!==null&&_e.current!==f){let q=be.find(ie=>ie.currency_code.toLowerCase()===f.toLowerCase());q&&y(String(q.default_amount??100));}_e.current=f;}},[f,be]),useEffect(()=>{async function q(){try{let ie=await Zl({chain_type:i||"",chain_id:s||"",token_address:l||""},t);oe(ie);}catch(ie){console.error("Error fetching supported tokens:",ie);}}q();},[i,s,l,t]),useEffect(()=>{async function q(){if(!(!l||!s||!i)&&!ce){de(true);try{let ie=await tc({country_code:ve?.alpha2?.toUpperCase()||"US",subdivision_code:ve?.state||void 0,token_address:l,chain_id:s,chain_type:i},t);Yt(ie);}catch(ie){console.error("Error fetching default onramp token:",ie);}finally{de(false);}}}q();},[l,s,i,ve,ce,t]),useEffect(()=>{let q=parseFloat(C);if(isNaN(q)||q<=0){A([]),fe(null);return}if(!ze||mt){A([]),Se(null);return}let ie=be.find(Fr=>Fr.currency_code.toLowerCase()===f.toLowerCase());if(ie){if(q<ie.minimum_amount){A([]),Se(null),fe(`Minimum amount is ${yd(f)}${ie.minimum_amount.toLocaleString()}`);return}if(q>ie.maximum_amount){A([]),Se(null),fe(`Maximum amount is ${yd(f)}${ie.maximum_amount.toLocaleString()}`);return}}fe(null);let wt=setTimeout(()=>{un(q);},500);return ()=>clearTimeout(wt)},[C,f,t,ze,mt,be]);let un=async q=>{if(!ze){W("Loading token information...");return}F(true),W(null);try{let ie={country_code:ve?.alpha2?.toUpperCase()||"US",source_amount:q.toString(),source_currency:f.toLowerCase(),destination_currency:ze.destination_currency,destination_network:ze.destination_network,subdivision_code:ve?.state||void 0},wt=await Xl(ie,t);A(wt.data);let Fr=We.current,ys=st.current;if(Fr&&ys){let ao=wt.data.find(lo=>lo.service_provider===ys.service_provider);if(ao){if(Se(ao),wt.data.length>0){let lo=wt.data.reduce((Dr,zo)=>zo.destination_amount>Dr.destination_amount?zo:Dr);Ge||ke(lo.service_provider),Ie(ao.service_provider===Ge);}}else if(wt.data.length>0){let lo=wt.data.reduce((Dr,zo)=>zo.destination_amount>Dr.destination_amount?zo:Dr);Se(lo),ke(lo.service_provider),Ie(!0),Te(!1);}}else if(wt.data.length>0){let ao=wt.data.reduce((lo,Dr)=>Dr.destination_amount>lo.destination_amount?Dr:lo);Se(ao),ke(ao.service_provider),Ie(!0);}X(60);}catch(ie){console.error("Failed to fetch quotes:",ie),W("Failed to fetch quotes. Please try again."),A([]);}finally{F(false);}};useEffect(()=>{if(I.length===0)return;let q=setInterval(()=>{X(ie=>{if(ie<=1){let wt=parseFloat(C);return !isNaN(wt)&&wt>0&&un(wt),60}return ie-1});},1e3);return ()=>clearInterval(q)},[I.length,C]);let Si=q=>{(/^\d*\.?\d{0,2}$/.test(q)||q==="")&&(y(q),k(true));},ki=q=>{y(q.toString()),k(true);},yo=async()=>{if(G&&ze)try{let q=ze.destination_token_metadata.chain_type,ie=Ho(Ye,q);if(!ie?.address){W("Wallet address not available");return}let wt={service_provider:G.service_provider,country_code:G.country_code?.toUpperCase()||ve?.alpha2?.toUpperCase()||"US",source_currency:G.source_currency,source_amount:C,destination_currency:G.destination_currency,destination_network:G.destination_network,wallet_address:ie.address,subdivision_code:ve?.state||void 0},Fr=await ec(wt,t);xr({provider:G,sourceCurrency:f,sourceAmount:C,sessionUrl:Fr.url}),j(Fr.url),xe(!0);}catch(q){console.error("Failed to create session:",q),W("Failed to start payment flow"),u?.({message:"Failed to start payment flow",error:q});}},Ti=yd(f),so=()=>{xe(false),ne("onramp"),m?.({message:"Payment flow completed"});},Mo=()=>jsx(Og,{visible:$t,onClose:so,url:at,providerName:G?.service_provider_display_name||"Complete Payment",colors:b,fonts:w,borderTopLeftRadius:g?.webView?.borderTopLeftRadius??h,borderTopRightRadius:g?.webView?.borderTopRightRadius??S});return re==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:N.amountViewContainer,children:[jsxs(BottomSheetScrollView,{style:N.scrollContainer,contentContainerStyle:N.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:N.currencySelector,children:jsxs(TouchableOpacity$1,{onPress:()=>io(true),style:[N.currencyButton,{backgroundColor:c.card.backgroundColor,borderRadius:c.input.borderRadius,borderWidth:c.input.borderWidth,borderColor:c.input.borderColor}],children:[ue&&jsx(Image,{source:{uri:J(ge(ue,"png"))},style:N.currencyIcon}),jsx(Text,{style:[N.currencyText,{color:c.card.titleColor,fontFamily:w.medium}],children:f.toUpperCase()}),jsx(Pt,{size:16,color:c.card.actionColor,strokeWidth:2})]})}),jsx(ml,{open:_t,onOpenChange:io,currencies:be,preferredCurrencyCodes:z,selectedCurrency:f,onSelectCurrency:q=>{d(q.toLowerCase()),_(true);},borderTopLeftRadius:g?.currencyModal?.borderTopLeftRadius??h,borderTopRightRadius:g?.currencyModal?.borderTopRightRadius??S}),jsx(View,{style:N.amountContainer,children:jsxs(View,{style:N.amountInputRow,children:[jsx(Text,{style:[N.currencySymbol,{color:c.container.titleColor,fontFamily:w.medium}],children:Ti}),jsx(TextInput,{style:[N.amountInput,{color:c.container.titleColor,fontFamily:w.medium}],value:C,onChangeText:Si,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:b.foregroundMuted})]})}),ue?.suggested_amounts&&ue.suggested_amounts.length>0&&jsx(View,{style:N.quickAmounts,children:ue.suggested_amounts.map(q=>jsx(TouchableOpacity$1,{onPress:()=>ki(q),style:[N.quickAmountButton,{backgroundColor:c.card.backgroundColor,borderRadius:c.button.borderRadius,borderWidth:parseFloat(C)===q?2:c.button.borderWidth,borderColor:parseFloat(C)===q?b.primary:c.button.borderColor}],children:jsxs(Text,{style:[N.quickAmountText,{color:c.card.titleColor,fontFamily:w.medium}],children:[Ti,q.toLocaleString()]})},q))}),$&&jsx(Text,{style:[N.validationError,{color:b.error,fontFamily:w.regular}],children:$}),jsxs(View,{style:N.providerSection,children:[jsxs(View,{style:N.providerHeader,children:[jsx(Text,{style:[N.providerLabel,{color:c.card.labelColor,fontFamily:w.medium}],children:"Provider"}),I.length>0&&!V&&jsxs(Text,{style:[N.refreshText,{color:c.card.labelRightColor,fontFamily:w.regular}],children:["Refreshing in ",pe,"s"]})]}),jsx(Gt,{cardTokens:c.depositCard.quoteProvider.card,onPress:V||I.length===0?void 0:()=>ir(true),contentStyle:StyleSheet.flatten([N.providerButton,(V||I.length===0)&&N.disabled]),children:V?jsxs(View,{style:N.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:c.container.subtitleColor}),jsx(Text,{style:[N.loadingText,{color:c.container.subtitleColor,fontFamily:w.regular}],children:"Finding best rates..."})]}):G?jsxs(View,{style:N.providerContent,children:[jsxs(View,{style:N.providerInfo,children:[he&&jsx(Text,{style:[N.autoPickedText,{color:c.container.subtitleColor,fontFamily:w.regular}],children:"Auto-picked for you"}),jsxs(View,{style:N.providerRow,children:[jsx(Image,{source:{uri:J(Sa(G.icon_urls,"png",G.icon_url))},style:N.providerIconImage},`provider-${G.service_provider}`),jsxs(View,{children:[jsx(Text,{style:[N.providerName,{color:c.card.titleColor,fontFamily:w.medium}],children:G.service_provider_display_name}),jsxs(Text,{style:[N.bestPriceText,{color:b.success,fontFamily:w.regular}],children:["Best price \u2022 ",G.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(Vr,{size:20,color:c.card.actionColor,strokeWidth:2})]}):jsx(Text,{style:[N.noProviderText,{color:c.container.subtitleColor,fontFamily:w.regular}],children:parseFloat(C)>0?"No providers available":"Enter an amount to see providers"})}),P&&jsx(Text,{style:[N.errorText,{color:b.error,fontFamily:w.regular}],children:P})]}),jsxs(ct,{visible:Or,onClose:()=>ir(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:g?.providerModal?.borderTopLeftRadius??h,borderTopRightRadius:g?.providerModal?.borderTopRightRadius??S,children:[jsx(kr,{title:"Select Provider",showBack:false,onClose:()=>ir(false)}),jsx(BottomSheetScrollView,{style:N.providerModalList,contentContainerStyle:N.providerModalListContent,showsVerticalScrollIndicator:false,children:jsx(View,{style:N.quotesList,children:[...I].sort((q,ie)=>ie.destination_amount-q.destination_amount).map((q,ie)=>{let wt=G?.service_provider===q.service_provider,Fr=ie===0;return jsxs(Gt,{cardTokens:c.depositCard.quoteProvider.card,onPress:()=>{Se(q),Te(true),Ie(q.service_provider===Ge),ir(false);},contentStyle:StyleSheet.flatten([N.quoteItem,wt&&{borderWidth:2,borderColor:b.primary}]),children:[jsxs(View,{style:N.quoteLeft,children:[jsx(Image,{source:{uri:J(Sa(q.icon_urls,"png",q.icon_url))},style:N.providerIconImage}),jsxs(View,{children:[jsx(Text,{style:[N.quoteName,{color:c.card.titleColor,fontFamily:w.medium}],children:q.service_provider_display_name}),Fr&&jsx(Text,{style:[N.bestPriceLabel,{color:b.success,fontFamily:w.regular}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:N.quoteRight,children:[jsxs(Text,{style:[N.quoteAmount,{color:c.card.textRightColor,fontFamily:w.medium}],children:[q.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[N.quoteSource,{color:c.card.subtextRightColor,fontFamily:w.regular}],children:["Fee: ",Ti,q.total_fee.toFixed(2)]})]})]},q.service_provider)})})})]})]}),jsx(View,{style:[N.continueButtonContainer,{backgroundColor:b.background}],children:jsx(View,{style:{opacity:V||Ee||!G||parseFloat(C)<=0?.5:1},children:jsx(TouchableOpacity$1,{onPress:yo,disabled:V||Ee||!G||parseFloat(C)<=0,style:[N.continueButton,{backgroundColor:c.container.buttonColor,borderRadius:c.button.borderRadius,borderWidth:c.button.borderWidth,borderColor:c.button.borderColor}],children:jsx(Text,{style:[N.continueButtonText,{color:c.container.buttonTitleColor,fontFamily:w.medium}],children:Ee?"Loading...":"Continue"})})})})]}),Mo()]}):re==="onramp"&&et?jsxs(View,{style:N.onrampContainer,children:[jsx(Image,{source:{uri:J(Sa(et.provider.icon_urls,"png",et.provider.icon_url))},style:N.onrampProviderIcon}),jsxs(Text,{style:[N.onrampTitle,{color:c.container.titleColor,fontFamily:w.medium}],children:["Complete transaction with ",et.provider.service_provider_display_name]}),jsx(Text,{style:[N.onrampSubtitle,{color:c.container.subtitleColor,fontFamily:w.regular}],children:"You can close this modal."}),jsxs(View,{style:[N.flowDiagram,{backgroundColor:c.card.backgroundColor}],children:[jsxs(View,{style:N.flowStep,children:[jsx(Image,{source:{uri:Ht(`/icons/currencies/png/${et.sourceCurrency.toLowerCase()}.png`)},style:N.flowIconImage}),jsx(Text,{style:[N.flowLabel,{color:c.card.subtitleColor,fontFamily:w.regular}],children:"You use"}),jsx(Text,{style:[N.flowValue,{color:c.card.titleColor,fontFamily:w.medium}],children:et.sourceCurrency.toUpperCase()})]}),jsx(Vr,{size:16,color:c.card.actionColor,strokeWidth:2}),jsxs(View,{style:N.flowStep,children:[jsxs(View,{style:N.flowIconWithBadge,children:[jsx(Image,{source:{uri:Fi(ze?.destination_token_metadata?.icon_urls,"png")||ze?.destination_token_metadata?.icon_url||Ht("/icons/tokens/png/usdc.png")},style:N.flowIconImageNoBadge}),jsx(Image,{source:{uri:Fi(ze?.destination_token_metadata?.chain?.icon_urls,"png")||ze?.destination_token_metadata?.chain?.icon_url||Ht("/icons/networks/png/polygon.png")},style:[N.flowNetworkBadge,{borderColor:b.background,borderRadius:c.badge.borderRadius}]})]}),jsx(Text,{style:[N.flowLabel,{color:c.card.subtitleColor,fontFamily:w.regular}],children:"You buy"}),jsx(Text,{style:[N.flowValue,{color:c.card.titleColor,fontFamily:w.medium}],children:"USDC"})]}),jsx(Vr,{size:16,color:c.card.actionColor,strokeWidth:2}),jsxs(View,{style:N.flowStep,children:[jsxs(View,{style:N.flowIconWithBadge,children:[jsx(Image,{source:{uri:ft||Ht("/icons/tokens/png/usdc.png")},style:N.flowIconImageNoBadge}),jsx(Image,{source:{uri:De||Ht("/icons/networks/png/polygon.png")},style:[N.flowNetworkBadge,{borderColor:b.background,borderRadius:c.badge.borderRadius}]})]}),jsx(Text,{style:[N.flowLabel,{color:c.card.subtitleColor,fontFamily:w.regular}],children:"You receive"}),jsx(Text,{style:[N.flowValue,{color:c.card.titleColor,fontFamily:w.medium}],children:O})]})]}),jsx(View,{style:[N.onrampInfoBox,{backgroundColor:c.card.backgroundColor,borderRadius:c.card.borderRadius,borderWidth:c.card.borderWidth,borderColor:c.card.borderColor}],children:jsx(Text,{style:[N.onrampInfoText,{color:c.card.descriptionColor,fontFamily:w.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 Og({visible:e,onClose:t,url:r,providerName:o,colors:n,fonts:a,borderTopLeftRadius:i,borderTopRightRadius:s}){return jsxs(ct,{visible:e,onClose:t,closeOnBackdropPress:false,enablePanDownToClose:false,showHandle:false,heightPercent:.92,noPadding:true,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:fi.header,children:[jsx(TouchableOpacity$1,{onPress:t,style:fi.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(qe,{size:20,color:n.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[fi.headerTitle,{color:n.foreground,fontFamily:a.medium}],children:o}),jsx(View,{style:fi.headerSpacer})]}),r&&jsx(View,{style:fi.container,children:jsx(WebView,{source:{uri:r},style:fi.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:fi.loading,children:jsx(ActivityIndicator,{size:"large",color:n.primary})})})})]})}var fi=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"}}),N=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"},bestPriceLabel:{fontSize:11,marginTop:2},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 Lg(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 Bg(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Cl({execution:e,onPress:t}){let {colors:r,fonts:o,components:n}=D(),a=n.depositTracker.executionRow.card,i=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let l=J(ge(e.destination_token_metadata,"png")||Ht("/icons/tokens/png/usdc.png")),m=i?"Deposit Processing":"Deposit Completed",u=Lg(e.created_at||new Date().toISOString()),h=Bg(e.source_amount_usd);return jsxs(Gt,{cardTokens:a,onPress:t,contentStyle:rn.container,children:[jsxs(View,{style:rn.iconContainer,children:[jsx(Image,{source:{uri:l},style:rn.tokenIcon}),jsx(View,{style:[rn.statusBadge,{backgroundColor:i?r.warning:r.success,borderColor:a.backgroundColor}],children:i?jsx(ha,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(qe,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:rn.textContainer,children:[jsx(Text,{style:[rn.title,{color:a.titleColor,fontFamily:o.medium}],children:m}),jsx(Text,{style:[rn.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:u})]}),jsxs(View,{style:rn.rightContainer,children:[jsx(Text,{style:[rn.amount,{color:a.textRightColor,fontFamily:o.medium}],children:h}),jsx(Vr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var rn=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 rm(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 om(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 Ag(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var nm=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function im(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function Eg(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 Mg({count:e=4}){let{colors:t,components:r}=D(),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:hi.list,children:Array.from({length:e}).map((i,s)=>jsxs(View,{style:[hi.row,{backgroundColor:n.backgroundColor,borderRadius:n.borderRadius??12,borderWidth:n.borderWidth,borderColor:n.borderColor}],children:[jsx(Animated.View,{style:[hi.icon,{backgroundColor:a,opacity:o}]}),jsxs(View,{style:hi.textBlock,children:[jsx(Animated.View,{style:[hi.titleBar,{backgroundColor:a,opacity:o}]}),jsx(Animated.View,{style:[hi.subtitleBar,{backgroundColor:a,opacity:o}]})]}),jsx(Animated.View,{style:[hi.amountBar,{backgroundColor:a,opacity:o}]})]},s))})}var hi=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 wd({active:e,onClose:t,executions:r,externalUserId:o,publishableKey:n}){let{colors:a,fonts:i,components:s}=D(),[l,m]=useState(r),[u,h]=useState(false),[S,g]=useState(null),[b,w]=useState(false),c=useRef(null);useEffect(()=>{if(!e||!o)return;let x=async()=>{h(true);try{let A=[...(await No(o,n)).data].sort((V,F)=>{let P=V.created_at?new Date(V.created_at).getTime():0;return (F.created_at?new Date(F.created_at).getTime():0)-P});m(A);}catch(I){console.error("Failed to fetch executions:",I),m(r);}finally{h(false);}};x();let k=setInterval(x,1e4);return ()=>clearInterval(k)},[e,o,n,r]),useEffect(()=>{r.length>0&&m(x=>{let k=new Set(x.map(A=>A.id)),I=r.filter(A=>!k.has(A.id));return I.length>0?[...I,...x]:x});},[r]),useEffect(()=>{e||g(null);},[e]);let C=x=>{g(x);},y=()=>{g(null),w(false);},f=()=>{g(null),t();},d=()=>{if(!S)return null;let x=S,k=x.status==="pending"||x.status==="waiting"||x.status==="delayed",I=x.status==="succeeded",A=J(ge(x.destination_token_metadata,"png")||Ht("/icons/tokens/png/usdc.png")),V=x.provider_metadata?.details,F=V?.currencyIn,P=V?.currencyOut;F?.currency?.symbol||"USDC";P?.currency?.symbol||"USDC";let fe=om(x.source_amount_base_unit,x.source_token_metadata?.decimals),Ke=om(x.destination_amount_base_unit,x.destination_token_metadata?.decimals),Fe=Ag(x.source_amount_usd),G=rm(x.source_chain_type,x.source_chain_id),Se=rm(x.destination_chain_type,x.destination_chain_id),he=()=>{x.explorer_url&&Linking.openURL(x.explorer_url);},Ie=()=>{x.destination_explorer_url&&Linking.openURL(x.destination_explorer_url);};return jsxs(BottomSheetScrollView,{ref:c,style:le.scrollContainer,contentContainerStyle:le.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:le.iconSection,children:[jsxs(View,{style:le.iconWrapper,children:[jsx(Image,{source:{uri:A},style:le.tokenIcon}),jsx(View,{style:[le.statusBadge,{backgroundColor:k?a.warning:a.success,borderColor:a.background}],children:k?jsx(Pt,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(qe,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:le.statusRow,children:[jsx(View,{style:[le.statusDot,{backgroundColor:k?a.warning:a.success}]}),jsx(Text,{style:[le.statusText,{color:s.container.titleColor,fontFamily:i.semibold}],children:k?"Processing":"Completed"})]}),jsx(Text,{style:[le.dateText,{color:s.container.subtitleColor,fontFamily:i.regular}],children:Eg(x.created_at||new Date().toISOString())})]}),jsxs(View,{style:[le.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Sent"}),jsxs(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[fe," ",im(x.source_currency)]})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Amount Received"}),jsxs(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:[Ke," ",im(x.destination_currency)]})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"USD Value"}),jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Fe})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Source Network"}),jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:G})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]}),jsxs(View,{style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Destination Network"}),jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:Se})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let Ge=!b;w(Ge),Ge?setTimeout(()=>{c.current?.scrollToEnd({animated:true});},100):c.current?.scrollTo({y:0,animated:true});},style:le.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[le.toggleText,{color:s.container.actionTitle,fontFamily:i.regular}],children:b?"See less":"See more details"}),b?jsx(wo,{size:14,color:s.container.actionColor,strokeWidth:2}):jsx(Pt,{size:14,color:s.container.actionColor,strokeWidth:2})]}),b&&jsxs(View,{style:[le.card,{backgroundColor:s.card.backgroundColor,borderRadius:s.card.borderRadius,borderWidth:s.card.borderWidth,borderColor:s.card.borderColor}],children:[x.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:he,style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Deposit Tx"}),jsxs(View,{style:le.cardRowRight,children:[jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:nm(x.transaction_hash)}),jsx(Co,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]}),jsx(View,{style:[le.cardDivider,{backgroundColor:a.border}]})]}),x.destination_explorer_url&&I&&jsxs(TouchableOpacity,{onPress:Ie,style:le.cardRow,children:[jsx(Text,{style:[le.cardLabel,{color:s.card.rowLeftLabel,fontFamily:i.regular}],children:"Completion Tx"}),jsxs(View,{style:le.cardRowRight,children:[jsx(Text,{style:[le.cardValue,{color:s.card.rowRightLabel,fontFamily:i.medium}],children:nm(x.destination_transaction_hashes[0])}),jsx(Co,{size:14,color:s.card.actionIcon,strokeWidth:2})]})]})]})]})},T=u&&l.length===0;return jsxs(Fragment,{children:[jsx(kr,{title:S?"Deposit Details":"Deposit Tracker",onClose:f,showClose:!S,showBack:!!S,onBack:y}),S?d():T?jsx(Mg,{}):jsx(BottomSheetScrollView,{style:le.scrollContainer,contentContainerStyle:le.scrollContent,showsVerticalScrollIndicator:false,children:l.length===0?jsxs(View,{style:le.emptyContainer,children:[jsx(Text,{style:[le.emptyText,{color:s.container.titleColor,fontFamily:i.medium}],children:"No deposits yet"}),jsx(Text,{style:[le.emptySubtext,{color:s.container.subtitleColor,fontFamily:i.regular}],children:"Your deposit history will appear here"})]}):jsx(View,{style:le.executionsList,children:l.map(x=>jsx(Cl,{execution:x,onPress:()=>C(x)},x.id))})})]})}var le=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,a]=useState(null),[i,s]=useState(false),[l,m]=useState(false),[u,h]=useState(null),[S,g]=useState(null);useEffect(()=>{!t||r||(s(true),Is().then(C=>{o(C),h(null);}).catch(C=>{h(C instanceof Error?C:new Error(String(C)));}).finally(()=>{s(false);}));},[t,r]),useEffect(()=>{!t||!e||n||(m(true),Rs(e).then(C=>{a(C),g(null);}).catch(C=>{g(C instanceof Error?C:new Error(String(C)));}).finally(()=>{m(false);}));},[t,e,n]);let b=i||l,w=u||S||null,c=null;if(r&&n){let C=n.blocked_country_codes||[],y=r.alpha2.toUpperCase();c=!C.some(f=>f.toUpperCase()===y);}return {isAllowed:c,alpha2:r?.alpha2?.toLowerCase()??null,country:r?.country??null,isLoading:b,error:w}}var Td="unifold_recent_tokens",jg=5,um=[{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 xl(){try{let e=await Tc.getItem(Td);return e?JSON.parse(e):[]}catch{return []}}async function $g(e){try{let r=(await xl()).filter(n=>!(n.symbol===e.symbol&&n.chainType===e.chainType&&n.chainId===e.chainId));r.unshift(e);let o=r.slice(0,jg);await Tc.setItem(Td,JSON.stringify(o));}catch{}}async function qg(e){try{let r=(await xl()).filter(o=>!(o.symbol===e.symbol&&o.chainType===e.chainType&&o.chainId===e.chainId));return await Tc.setItem(Td,JSON.stringify(r)),r}catch{return []}}function xd({visible:e,onClose:t,tokens:r,selectedToken:o,selectedChainKey:n,onSelect:a,borderTopLeftRadius:i,borderTopRightRadius:s}){let{colors:l,fonts:m,components:u}=D(),[h,S]=useState(""),[g,b]=useState([]);useEffect(()=>{e&&xl().then(b);},[e]),useEffect(()=>{e||S("");},[e]);let w=useMemo(()=>{let T=[];return r.forEach(_=>{_.chains.forEach(x=>{T.push({token:_,chain:x});});}),T},[r]),c=useMemo(()=>{let T=[],_=new Set,x=(k,I,A,V)=>{let F=`${k}-${I}:${A}`;if(_.has(F))return;let P=r.find($=>$.symbol===k);if(!P)return;let W=P.chains.find($=>$.chain_type===I&&$.chain_id===A);W&&(_.add(F),T.push({token:P,chain:W,isRecent:V}));};return g.forEach(k=>{x(k.symbol,k.chainType,k.chainId,true);}),um.forEach(k=>{x(k.symbol,k.chainType,k.chainId,false);}),T},[r,g]),C=useMemo(()=>{if(!h.trim())return w;let T=h.toLowerCase();return w.filter(({token:_,chain:x})=>_.symbol.toLowerCase().includes(T)||_.name.toLowerCase().includes(T)||x.chain_name.toLowerCase().includes(T))},[w,h]),y=(T,_,x)=>um.some(k=>k.symbol===T&&k.chainType===_&&k.chainId===x),f=async(T,_)=>{let x=`${_.chain_type}:${_.chain_id}`;if(!y(T.symbol,_.chain_type,_.chain_id)){await $g({symbol:T.symbol,chainType:_.chain_type,chainId:_.chain_id});let k=await xl();b(k);}S(""),a(T.symbol,x),t();},d=async(T,_)=>{let x=await qg({symbol:T.symbol,chainType:_.chain_type,chainId:_.chain_id});b(x);};return jsxs(ct,{visible:e,onClose:t,closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,startExpanded:false,borderTopLeftRadius:i,borderTopRightRadius:s,children:[jsxs(View,{style:it.header,children:[jsx(View,{style:it.headerSpacer}),jsx(Text,{style:[it.headerTitle,{color:u.header.titleColor,fontFamily:m.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:t,style:it.closeButton,children:jsx(tt,{size:20,color:u.header.buttonColor,strokeWidth:2})})]}),jsx(View,{style:it.searchContainer,children:jsx(TextInput,{style:[it.searchInput,{backgroundColor:u.search.backgroundColor,color:u.search.inputColor,fontFamily:m.regular,borderRadius:u.input.borderRadius,borderWidth:u.input.borderWidth,borderColor:u.input.borderColor}],placeholder:"Search",placeholderTextColor:u.search.placeholderColor,value:h,onChangeText:S,autoCapitalize:"none",autoCorrect:false})}),c.length>0&&!h&&jsxs(View,{style:it.quickSelectSection,children:[jsx(Text,{style:[it.sectionLabel,{color:u.list.titleSectionColor,fontFamily:m.regular}],children:"Quick select"}),jsx(ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:it.quickSelectScroll,children:c.map(({token:T,chain:_,isRecent:x})=>{let k=`${_.chain_type}:${_.chain_id}`;T.symbol===o&&k===n;return jsxs(View,{children:[x&&jsx(TouchableOpacity$1,{onPress:()=>d(T,_),style:it.removeButton,children:jsx(tt,{size:12,color:l.foregroundMuted,strokeWidth:2})}),jsxs(TouchableOpacity$1,{onPress:()=>f(T,_),activeOpacity:.7,style:[it.quickSelectItem,{backgroundColor:u.card.backgroundColor,borderRadius:u.card.borderRadius,borderWidth:u.card.borderWidth,borderColor:u.card.borderColor}],children:[jsxs(View,{style:it.tokenIconContainer,children:[jsx(Image,{source:{uri:J(ge(T,"png"))},style:it.quickSelectIcon}),jsx(Image,{source:{uri:J(ge(_,"png"))},style:[it.quickSelectChainBadge,{borderColor:u.card.backgroundColor,borderRadius:u.badge.borderRadius}]})]}),jsxs(View,{style:it.quickSelectText,children:[jsx(Text,{style:[it.quickSelectSymbol,{color:u.card.titleColor,fontFamily:m.medium}],children:T.symbol}),jsx(Text,{style:[it.quickSelectChain,{color:u.card.subtitleColor,fontFamily:m.regular}],children:_.chain_name})]})]})]},`quick-${T.symbol}-${k}`)})})]}),jsx(Text,{style:[it.sectionLabel,{color:u.list.titleSectionColor,fontFamily:m.regular}],children:"All supported tokens"}),jsx(BottomSheetScrollView,{style:it.tokenList,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",contentContainerStyle:it.tokenListContent,children:C.length===0?jsx(View,{style:it.emptyState,children:jsx(Text,{style:[it.emptyText,{color:l.foregroundMuted,fontFamily:m.regular}],children:"No tokens found"})}):C.map(({token:T,chain:_})=>{let x=`${_.chain_type}:${_.chain_id}`,k=T.symbol===o&&x===n;return jsxs(TouchableOpacity$1,{onPress:()=>f(T,_),activeOpacity:.7,style:[it.tokenItem,{backgroundColor:k?u.card.backgroundColor:"transparent"}],children:[jsxs(View,{style:it.tokenIconContainerLarge,children:[jsx(Image,{source:{uri:J(ge(T,"png"))},style:it.tokenIcon}),jsx(Image,{source:{uri:J(ge(_,"png"))},style:[it.tokenChainBadge,{borderColor:u.card.backgroundColor,borderRadius:u.badge.borderRadius}]})]}),jsxs(View,{style:it.tokenInfo,children:[jsx(Text,{style:[it.tokenSymbol,{color:u.card.titleColor,fontFamily:m.medium}],children:T.symbol}),jsx(Text,{style:[it.tokenChainName,{color:u.card.subtitleColor,fontFamily:m.regular}],children:_.chain_name})]}),jsxs(Text,{style:[it.minDeposit,{color:u.card.labelColor,fontFamily:m.regular}],children:["Minimum:"," ",jsxs(Text,{style:{color:u.card.labelHighlightRightColor,fontFamily:m.regular},children:["$",_.minimum_deposit_amount_usd]})]})]},`${T.symbol}-${x}`)})})]})}var it=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 Rl=(e,t)=>`${t}:${e}`,Jg=e=>{let[t,r]=e.split(":");return {chainType:t,chainId:r}};function _d({externalUserId:e,publishableKey:t,recipientAddress:r,destinationChainType:o,destinationChainId:n,destinationTokenAddress:a,destinationTokenSymbol:i,defaultChainType:s,defaultChainId:l,defaultTokenAddress:m,depositConfirmationMode:u="auto_ui",onExecutionsChange:h,onDepositSuccess:S,onDepositError:g,wallets:b,borderTopLeftRadius:w,borderTopRightRadius:c,sheetBorderRadius:C}){let{colors:y,fonts:f,components:d}=D(),T=s&&l?`${s}:${l}`:"solana:mainnet",[_,x]=useState("USDC"),[k,I]=useState(T),[A,V]=useState([]),[F,P]=useState(!b?.length),W=b?.length?b:A,[$,fe]=useState([]),[Ke,Fe]=useState(true),[G,Se]=useState(false),[he,Ie]=useState(false),[Ge,ke]=useState(false),[te,Te]=useState([]),[st,We]=useState(new Map),[Ye]=useState(()=>new Date),[Ae,Ee]=useState(null),[Me,pe]=useState(false),[X,be]=useState(null),[pt,z]=useState(false),E=new Map;$.forEach(xe=>{xe.chains.forEach(at=>{let j=`${at.chain_type}:${at.chain_id}`;E.has(j)||E.set(j,at);});});let se=Array.from(E.values()),oe=Jg(k),ve=se.find(xe=>xe.chain_type===oe.chainType&&xe.chain_id===oe.chainId),xt=ve?.chain_type||"ethereum",ce=Ho(W,xt),ae=ce?.address||"",ze=useRef(false);useEffect(()=>{async function xe(){try{Fe(!0),Ee(null);let j=await Nn(t,a&&n&&o?{destination_token_address:a,destination_chain_id:n,destination_chain_type:o}:void 0);if(fe(j.data),j.data.length>0&&!ze.current){ze.current=!0;let re,_e;if(s&&l)if(m)for(let ue of j.data){let ne=ue.chains.find(O=>O.chain_type===s&&O.chain_id===l&&O.token_address.toLowerCase()===m.toLowerCase());if(ne){re=ue,_e=ne;break}}else for(let ue of j.data){let ne=ue.chains.find(O=>O.chain_type===s&&O.chain_id===l);if(ne){re=ue,_e=ne;break}}if(!re&&a)for(let ue of j.data){let ne=ue.chains.find(O=>O.token_address.toLowerCase()===a.toLowerCase());if(ne){re=ue,_e=ne;break}}re||(re=j.data.find(ue=>ue.symbol==="USDC"),re&&re.chains.length>0&&(_e=re.chains[0])),re||(re=j.data.find(ue=>ue.symbol==="USDT"),re&&re.chains.length>0&&(_e=re.chains[0])),re||(re=j.data[0],re.chains.length>0&&(_e=re.chains[0])),re&&x(re.symbol),_e&&I(Rl(_e.chain_id,_e.chain_type));}}catch(at){console.error("Error fetching supported tokens:",at),Ee("Failed to load supported tokens"),g?.({message:"Failed to load supported tokens",error:at});}finally{Fe(false);}}xe();},[t,a,n,o,s,l,m,g]),useEffect(()=>{h&&h(te);},[te,h]),useEffect(()=>{if(b?.length){P(false);return}if(A.length>0){P(false);return}let xe=null,at=false,j=async()=>{if(!at){P(true);try{let re=await Uo({external_user_id:e,recipient_address:r,destination_chain_type:o,destination_chain_id:n,destination_token_address:a},t);at||(V(re.data),Ee(null),P(!1));}catch(re){console.error("Error fetching wallets, retrying in 5s:",re),at||(Ee(re instanceof Error?re.message:"Failed to load wallets"),P(false),xe=setTimeout(j,5e3));}}};return j(),()=>{at=true,xe&&clearTimeout(xe);}},[e,r,o,n,a,t,b,A.length]);let Yt=ce?.id??"",{showWaitingUi:mt,handleIveDeposited:de}=ea({depositConfirmationMode:u,depositAddress:ae,chain:k,externalUserId:e,publishableKey:t,modalOpenedAt:Ye,depositWalletId:Yt,depositExecutions:te,trackedExecutions:st,setDepositExecutions:Te,setTrackedExecutions:We,setLatestExecution:be,setShowStatusSheet:pe,onDepositSuccess:S,onExecutionsChange:h,onDepositError:g});useEffect(()=>{if(!$.length)return;let xe=$.find(j=>j.symbol===_);if(!xe||xe.chains.length===0)return;if(!xe.chains.some(j=>Rl(j.chain_id,j.chain_type)===k)){let j=xe.chains[0];I(Rl(j.chain_id,j.chain_type));}},[_,$,k]);let et=$.find(xe=>xe.symbol===_),_t=(et?.chains||[]).find(xe=>Rl(xe.chain_id,xe.chain_type)===k),io=async()=>{if(ae)try{Clipboard.setString(ae),Se(!0),setTimeout(()=>Se(!1),2e3);}catch(xe){console.error("Failed to copy:",xe);}},Or=_t?.estimated_price_impact_percent??0,ir=_t?.max_slippage_percent??.25,$t=_t?.minimum_deposit_amount_usd??3;return Ke?jsxs(View,{style:U.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:y.primary}),jsx(Text,{style:[U.loadingText,{color:y.foregroundMuted,fontFamily:f.regular}],children:"Loading currencies..."})]}):Ae&&$.length===0?jsxs(View,{style:U.errorContainer,children:[jsx(Text,{style:[U.errorText,{color:y.error,fontFamily:f.regular}],children:Ae}),jsx(Text,{style:[U.errorHint,{color:y.foregroundMuted,fontFamily:f.regular}],children:"Please check your network connection and try again."})]}):jsxs(View,{style:U.container,children:[jsxs(View,{style:U.selectorSection,children:[jsx(Text,{style:[U.selectorLabel,{color:d.card.labelColor,fontFamily:f.medium}],children:"Select token to deposit"}),jsx(TouchableOpacity$1,{onPress:()=>ke(true),disabled:Ke||$.length===0,style:[U.tokenSelectorButton,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],activeOpacity:.7,children:Ke?jsxs(View,{style:U.tokenSelectorLoading,children:[jsx(View,{style:[U.loadingIcon,{backgroundColor:y.cardHover}]}),jsxs(View,{style:U.loadingTextContainer,children:[jsx(View,{style:[U.loadingLine,{backgroundColor:y.cardHover,width:60}]}),jsx(View,{style:[U.loadingLine,{backgroundColor:y.cardHover,width:100,marginTop:4}]})]})]}):jsxs(Fragment,{children:[jsxs(View,{style:U.tokenIconWrapper,children:[et&&jsx(Image,{source:{uri:J(ge(et,"png"))},style:U.tokenMainIcon}),(_t||ve)&&jsx(Image,{source:{uri:J(ge(_t||ve,"png"))},style:[U.tokenChainBadge,{borderColor:d.card.backgroundColor,borderRadius:d.badge.borderRadius}]})]}),jsxs(View,{style:U.tokenSelectorInfo,children:[jsx(Text,{style:[U.tokenSelectorSymbol,{color:d.card.titleColor,fontFamily:f.semibold}],children:et?.symbol||_}),jsx(Text,{style:[U.tokenSelectorNetwork,{color:d.card.subtitleColor,fontFamily:f.regular}],numberOfLines:1,children:_t?.chain_name||ve?.chain_name||"Select network"})]}),jsxs(View,{style:U.tokenSelectorRight,children:[jsxs(Text,{style:[U.minDepositText,{color:d.card.labelHighlightRightColor,fontFamily:f.medium}],children:["$",$t," min"]}),jsx(Vr,{size:16,color:d.card.actionColor,strokeWidth:2})]})]})})]}),jsx(xd,{visible:Ge,onClose:()=>ke(false),tokens:$,selectedToken:_,selectedChainKey:k,onSelect:(xe,at)=>{x(xe),I(at);},borderTopLeftRadius:C?.tokenSelector?.borderTopLeftRadius??w,borderTopRightRadius:C?.tokenSelector?.borderTopRightRadius??c}),jsx(View,{style:U.qrContainer,children:jsx(View,{style:[U.qrWrapper,{backgroundColor:y.background,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth>0?d.card.borderWidth:1,borderColor:d.card.borderColor}],children:F?jsxs(View,{style:U.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:y.primary}),jsx(Text,{style:[U.loadingText,{color:y.foregroundMuted,fontFamily:f.regular}],children:"Loading..."})]}):ae?jsx(ss,{value:ae,size:180,logoUri:J(ge(_t,"png")||Ht("/icons/networks/png/ethereum.png")),logoSize:45}):jsx(View,{style:U.qrLoading,children:jsx(Text,{style:[U.errorText,{color:y.error,fontFamily:f.regular}],children:"No address available"})})})}),jsxs(View,{style:U.addressSection,children:[jsxs(View,{style:U.addressHeader,children:[jsx(Text,{style:[U.addressLabel,{color:d.card.labelColor,fontFamily:f.medium}],children:"Deposit Address"}),G&&jsxs(View,{style:U.copiedIndicator,children:[jsx(qe,{size:14,color:y.success,strokeWidth:2}),jsx(Text,{style:[U.copiedText,{color:y.success,fontFamily:f.regular}],children:"Copied"})]})]}),jsxs(Gt,{cardTokens:d.transferCrypto.depositAddress.card,onPress:!F&&ae?io:void 0,contentStyle:U.addressBox,children:[jsx(Text,{style:[U.addressText,{color:d.card.titleColor,fontFamily:f.regular}],numberOfLines:2,children:F?"Loading...":ae||"No address available"}),jsx(View,{style:U.addressCopyIcon,children:jsx(Hn,{size:16,color:d.card.actionColor,strokeWidth:1})})]})]}),jsxs(View,{style:[U.detailsCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(TouchableOpacity$1,{onPress:()=>Ie(!he),style:U.detailsHeader,children:[jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(bo,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.detailsLabel,{color:d.card.titleColor,fontFamily:f.regular}],children:"Processing time: < 1 min"})]}),jsx(View,{style:U.chevronContainer,children:he?jsx(wo,{size:16,color:d.card.actionColor,strokeWidth:2}):jsx(Pt,{size:16,color:d.card.actionColor,strokeWidth:2})})]}),he&&jsxs(View,{style:U.detailsContent,children:[jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:d.card.titleColor,fontFamily:f.regular}],children:["Price impact: ",Or.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>z(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ii,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:d.card.titleColor,fontFamily:f.regular}],children:["Slippage: Auto \u2022 ",ir.toFixed(2),"%"]}),jsx(TouchableOpacity$1,{onPress:()=>z(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ii,{size:14,color:d.card.actionColor,strokeWidth:2})})]}),jsxs(View,{style:U.detailsRow,children:[jsx(View,{style:[U.detailIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(fa,{size:12,color:d.card.iconColor,strokeWidth:2})}),jsxs(Text,{style:[U.detailsLabel,{color:d.card.titleColor,fontFamily:f.regular}],children:["Need help?"," ",jsx(Text,{style:{textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(ll,{depositConfirmationMode:u,depositAddress:ae,showWaitingUi:mt,latestExecution:X,onIveDeposited:de}),jsx(TouchableOpacity$1,{style:U.termsContainer,onPress:()=>Linking.openURL("https://unifold.io/terms"),children:jsx(Text,{style:[U.termsText,{color:y.primary,fontFamily:f.regular}],children:"Terms apply"})}),jsxs(ct,{visible:pt,onClose:()=>z(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.55,maxHeightPercent:.9,borderTopLeftRadius:C?.infoSheet?.borderTopLeftRadius??w,borderTopRightRadius:C?.infoSheet?.borderTopRightRadius??c,children:[jsxs(View,{style:[U.sheetHeader,{borderBottomColor:y.border}],children:[jsx(View,{style:U.sheetHeaderSpacer}),jsx(Text,{style:[U.sheetTitle,{color:d.header.titleColor,fontFamily:f.medium}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity$1,{onPress:()=>z(false),style:U.sheetCloseButton,children:jsx(tt,{size:20,color:d.header.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:U.infoSheetContent,children:[jsxs(View,{style:[U.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:U.infoCardHeader,children:[jsx(View,{style:[U.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(mn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.infoCardTitle,{color:d.card.titleColor,fontFamily:f.medium}],children:"Price Impact"}),jsxs(Text,{style:[U.infoCardValue,{color:d.card.titleColor,fontFamily:f.medium}],children:[Or.toFixed(2),"%"]})]}),jsx(Text,{style:[U.infoCardDescription,{color:d.card.descriptionColor,fontFamily:f.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:[U.infoCard,{backgroundColor:d.card.backgroundColor,borderRadius:d.card.borderRadius,borderWidth:d.card.borderWidth,borderColor:d.card.borderColor}],children:[jsxs(View,{style:U.infoCardHeader,children:[jsx(View,{style:[U.infoCardIcon,{backgroundColor:d.card.iconBackgroundColor,borderRadius:d.card.iconContainerBorderRadius}],children:jsx(fn,{size:16,color:d.card.iconColor,strokeWidth:2})}),jsx(Text,{style:[U.infoCardTitle,{color:d.card.titleColor,fontFamily:f.medium}],children:"Max Slippage"}),jsxs(Text,{style:[U.infoCardValue,{color:d.card.titleColor,fontFamily:f.medium}],children:[ir.toFixed(2),"%"]})]}),jsx(Text,{style:[U.infoCardDescription,{color:d.card.descriptionColor,fontFamily:f.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."})]})]})]}),X&&jsx(as,{visible:Me,status:X.status,tokenIconUrl:X.destination_token_metadata?.icon_urls?.find(xe=>xe.format==="png")?.url||X.destination_token_metadata?.icon_url||ge(et,"png"),explorerUrl:X.explorer_url,completionExplorerUrl:X.destination_explorer_url,date:X.created_at?new Date(X.created_at):void 0,amountUsd:X.source_amount_usd?parseFloat(X.source_amount_usd):void 0,onClose:()=>pe(false),borderTopLeftRadius:C?.depositStatus?.borderTopLeftRadius??w,borderTopRightRadius:C?.depositStatus?.borderTopRightRadius??c})]})}var U=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 sn={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 ry(){let{colors:e,components:t}=D(),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:[zn.card,{backgroundColor:o,borderRadius:t.depositMenu.card.borderRadius}],children:[jsx(Animated.View,{style:[zn.leftIcon,{backgroundColor:n,opacity:r,borderRadius:t.depositMenu.card.iconContainerBorderRadius}]}),jsxs(View,{style:zn.textBlock,children:[jsx(Animated.View,{style:[zn.titleBar,{backgroundColor:n,opacity:r}]}),jsx(Animated.View,{style:[zn.subtitleBar,{backgroundColor:n,opacity:r}]})]}),jsx(View,{style:zn.rightIcons,children:Array.from({length:i}).map((s,l)=>jsx(Animated.View,{style:[zn.rightIcon,{backgroundColor:n,opacity:r}]},l))})]});return jsxs(View,{style:zn.container,children:[jsx(a,{rightIcons:3}),jsx(a,{rightIcons:2}),jsx(a,{rightIcons:0})]})}var zn=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 oy({visible:e,onClose:t,externalUserId:r,publishableKey:o,modalTitle:n="Deposit",destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,defaultChainType:u,defaultChainId:h,defaultTokenAddress:S,showBalance:g=false,hideDepositTracker:b=false,enableStripeLinkPay:w=false,StripeOnrampComponent:c,stripeOnrampEmail:C,stripeOnrampPhone:y,stripeMerchantIdentifier:f,stripePaymentSelectorPosition:d,stripeSkipSuccessConfirmation:T,stripeTheme:_,depositConfirmationMode:x="auto_ui",transferInputVariant:k="double_input",initialScreen:I="main",onDepositSuccess:A,onDepositError:V,sheetBorderRadius:F}){let P=F?.globalBorderTopLeftRadius,W=F?.globalBorderTopRightRadius,{colors:$,fonts:fe}=D(),[Ke,Fe]=useState([]),[G,Se]=useState(null),[he,Ie]=useState("amount"),Ge=I==="tracker"&&!b?"tracker":I==="transfer"?"transfer":I==="card"?"card":"main",ke=Ge==="main",[te,Te]=useState(Ge),{isAllowed:st,isLoading:We}=na(o,e);useEffect(()=>{if(!e||G)return;let ce=false;return Rs(o).then(async ae=>{if(ce)return;let ze=[];for(let Yt of ae?.transfer_crypto?.networks??[]){let mt=Yt.icon_urls.find(de=>de.format==="png")?.url||Yt.icon_urls.find(de=>de.format==="svg")?.url;mt&&ze.push(J(mt));}for(let Yt of ae?.payment_networks?.networks??[]){let mt=Yt.icon_urls.find(de=>de.format==="png")?.url||Yt.icon_urls.find(de=>de.format==="svg")?.url;mt&&ze.push(J(mt));}ze.length>0&&await Yc(ze),ce||Se(ae);}).catch(console.error),()=>{ce=true;}},[e,G,o]);let Ye=()=>{t();};useEffect(()=>{e&&(Te(Ge),Ie("amount"));},[e,Ge]);let Ae=useCallback(()=>{ke?(Te("main"),Ie("amount")):Ye();},[ke,Ye]),Ee=Ke.filter(ce=>ce.status==="pending"||ce.status==="waiting").length,pe=!!(i&&s&&l&&m&&o)&&g!==false&&!!G,X=We||e&&!G,be=st===false,pt=null;if(te==="stripe"&&c){let ce=jsx(c,{publishableKey:o,email:C,phone:y,externalUserId:r,recipientAddress:i??"",destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,merchantIdentifier:f,paymentSelectorPosition:d,skipSuccessConfirmation:T,onClose:Ae});pt=_?jsx(vi,{..._,children:ce}):ce;}let z=te==="stripe"?.9:te==="transfer"||te==="card"?.94:te==="tracker"?.6:te==="main"?.5:void 0,E=te==="tracker"||te==="main"?.9:void 0,oe={main:F?.main,transfer:F?.transferCrypto,card:F?.buyWithCard,stripe:F?.stripeLinkPay,tracker:F?.depositsTracker}[te],ve=oe?.borderTopLeftRadius??P,xt=oe?.borderTopRightRadius??W;return jsxs(ct,{visible:e,onClose:te==="main"?Ye:Ae,closeOnBackdropPress:false,enablePanDownToClose:true,showHandle:true,heightPercent:z,maxHeightPercent:E,borderTopLeftRadius:ve,borderTopRightRadius:xt,children:[te==="main"&&jsxs(Fragment,{children:[jsx(kr,{title:n,showBack:false,onClose:Ye,showBalance:pe,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:G?.project_name}),X&&jsx(ry,{}),!X&&be&&jsxs(View,{style:br.centeredContainer,children:[jsx(View,{style:[br.iconContainer,{backgroundColor:$.cardHover}],children:jsx(ks,{size:32,color:$.foreground,strokeWidth:1.5})}),jsx(Text,{style:[br.blockedTitle,{color:$.foreground,fontFamily:fe.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[br.blockedDescription,{color:$.foreground,opacity:.7,fontFamily:fe.regular}],children:"There are no supported tokens available from your current location."})]}),!X&&!be&&jsxs(View,{style:br.optionsContainer,children:[jsx(Ks,{onPress:()=>Te("transfer"),title:sn.transferCrypto.title,subtitle:sn.transferCrypto.subtitle,featuredTokens:G?.transfer_crypto?.networks}),jsx(Ys,{onPress:()=>Te("card"),title:sn.depositWithCard.title,subtitle:sn.depositWithCard.subtitle,paymentNetworks:G?.payment_networks?.networks}),w&&c&&jsx(Xs,{onPress:()=>Te("stripe"),title:sn.stripeLinkPay.title,subtitle:sn.stripeLinkPay.subtitle}),!b&&jsx(Js,{onPress:()=>Te("tracker"),title:sn.depositTracker.title,subtitle:sn.depositTracker.subtitle,badge:Ee>0?Ee:void 0})]})]}),te==="transfer"&&jsxs(Fragment,{children:[jsx(kr,{title:sn.transferCrypto.title,showBack:false,onClose:Ae,showBalance:pe,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:G?.project_name}),We&&jsx(View,{style:[br.centeredContainer,br.centeredFlex],children:jsx(ActivityIndicator,{color:$.foreground})}),!We&&be&&jsxs(View,{style:[br.centeredContainer,br.centeredFlex],children:[jsx(View,{style:[br.iconContainer,{backgroundColor:$.cardHover}],children:jsx(ks,{size:32,color:$.foreground,strokeWidth:1.5})}),jsx(Text,{style:[br.blockedTitle,{color:$.foreground,fontFamily:fe.semibold}],children:"No Tokens Available"}),jsx(Text,{style:[br.blockedDescription,{color:$.foreground,opacity:.7,fontFamily:fe.regular}],children:"There are no supported tokens available from your current location."})]}),!We&&!be&&jsx(BottomSheetScrollView,{style:br.transferScrollContainer,contentContainerStyle:br.scrollContent,showsVerticalScrollIndicator:false,children:k==="single_input"?jsx(_d,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:u,defaultChainId:h,defaultTokenAddress:S,depositConfirmationMode:x,onExecutionsChange:Fe,onDepositSuccess:A,onDepositError:V,borderTopLeftRadius:P,borderTopRightRadius:W,sheetBorderRadius:{tokenSelector:F?.tokenSelector,infoSheet:F?.infoSheet,depositStatus:F?.depositStatus}}):jsx(dl,{externalUserId:r,publishableKey:o,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,destinationTokenSymbol:a,defaultChainType:u,defaultChainId:h,defaultTokenAddress:S,depositConfirmationMode:x,onExecutionsChange:Fe,onDepositSuccess:A,onDepositError:V,borderTopLeftRadius:P,borderTopRightRadius:W,sheetBorderRadius:{tokenSelector:F?.tokenSelector,chainSelector:F?.chainSelector,infoSheet:F?.infoSheet,depositStatus:F?.depositStatus}})})]}),te==="card"&&jsxs(Fragment,{children:[jsx(kr,{title:`Deposit ${a||"USDC"}`,showBack:he==="onramp",onBack:()=>Ie("amount"),onClose:Ae,showBalance:pe,balanceAddress:i,balanceChainType:s,balanceChainId:l,balanceTokenAddress:m,publishableKey:o,projectName:G?.project_name}),jsx(View,{style:br.buyWithCardContainer,children:jsx(gl,{externalUserId:r,publishableKey:o,destinationTokenSymbol:a,recipientAddress:i,destinationChainType:s,destinationChainId:l,destinationTokenAddress:m,onDepositSuccess:A,onDepositError:V,view:he,onViewChange:ce=>Ie(ce),borderTopLeftRadius:P,borderTopRightRadius:W,sheetBorderRadius:{providerModal:F?.providerModal,webView:F?.webView,currencyModal:F?.currencyModal}})})]}),te==="stripe"&&pt&&jsx(View,{style:br.stripeLinkPayContainer,children:pt}),te==="tracker"&&jsx(wd,{active:te==="tracker",onClose:Ae,executions:Ke,externalUserId:r,publishableKey:o})]})}function Pl({theme:e="auto",...t}){return jsx(oy,{...t})}var br=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 Ol(e,t=true){return Yo({queryKey:["unifold","supportedDestinationTokens",e],queryFn:()=>Ta(e),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false,enabled:t})}function vd(e){let{sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,publishableKey:a,enabled:i=true}=e;return Yo({queryKey:["unifold","sourceTokenValidation",t??null,r??null,o??null,a],queryFn:async()=>{let l=await Nn(a),m=null,u=null,h=null,S=null,g,b,w,c=l.data.some(C=>C.chains.some(y=>{let f=y.chain_type===t&&y.chain_id===r&&y.token_address.toLowerCase()===o.toLowerCase();return f&&(m=y.minimum_deposit_amount_usd,u=y.estimated_processing_time,h=y.max_slippage_percent,S=y.estimated_price_impact_percent,w=y.chain_name,b=C),f}));if(b){let C=ge(b,"png");C&&(g=J(C));}return {isSupported:c,minimumAmountUsd:m,estimatedProcessingTime:u,maxSlippagePercent:h,priceImpactPercent:S,errorMessage:c?null:`${n||"Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`,iconUrl:g,chainName:w}},enabled:i&&(!!t&&!!r&&!!o),staleTime:1e3*60*5,gcTime:1e3*60*30,refetchOnMount:false})}function Pd(e){let{address:t,chainType:r,chainId:o,tokenAddress:n,publishableKey:a,enabled:i=true}=e;return Yo({queryKey:["unifold","addressBalance",t??null,r??null,o??null,n??null,a],queryFn:async()=>{let l=await xa(t,r,o,n,a);if(l.balance){let m=l.balance.token?.decimals??6,u=l.balance.token?.symbol??"",h=l.balance.amount,S=BigInt(h),g=BigInt(10**m),b=S/g,c=(S%g).toString().padStart(m,"0").replace(/0+$/,""),C=c?`${b}.${c}`:b.toString();return {balanceBaseUnit:h,balanceHuman:C,balanceUsd:l.balance.amount_usd,exchangeRate:l.balance.exchange_rate,decimals:m,symbol:u}}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 iy=2500,sy=3e3,ay=6e4;function Od({userId:e,publishableKey:t,depositWalletId:r,enabled:o=false,onWithdrawSuccess:n,onWithdrawError:a}){let[i,s]=useState([]),[l,m]=useState(false),u=useRef(new Date),h=useRef(new Map),S=useRef(false),g=useRef(n),b=useRef(a);return useEffect(()=>{g.current=n;},[n]),useEffect(()=>{b.current=a;},[a]),useEffect(()=>{o&&!S.current&&(u.current=new Date,h.current.clear()),o||h.current.clear(),S.current=o;},[o]),useEffect(()=>{if(!e||!o)return;let w=u.current,c=async()=>{try{let y=await No(e,t,"withdraw"),f=new Date(w.getTime()-ay),d=[...y.data].sort((k,I)=>{let A=k.created_at?new Date(k.created_at).getTime():0;return (I.created_at?new Date(I.created_at).getTime():0)-A}),T=["pending","waiting","delayed"],_=["succeeded","failed"],x=null;for(let k of d){let I=k.created_at?new Date(k.created_at):null;if(!I||I<f)continue;let A=h.current.get(k.id);if(!A){x=k;break}if(T.includes(A)&&_.includes(k.status)){x=k;break}}if(x){let k=x,I=k.created_at?new Date(k.created_at):null;if(!I||I<u.current)return;let A=h.current.get(k.id);h.current.set(k.id,k.status),s(V=>{let F=V.findIndex(P=>P.id===k.id);if(F>=0){let P=[...V];return P[F]=k,P}return [...V,k]}),k.status==="succeeded"&&(!A||T.includes(A))?g.current?.({message:"Withdrawal completed successfully",transaction:k}):k.status==="failed"&&A!=="failed"&&b.current?.({message:"Withdrawal failed",code:"WITHDRAW_FAILED",error:k});}}catch(y){console.error("Failed to fetch withdraw executions:",y),b.current?.({message:"Failed to fetch withdrawal status",code:"POLLING_ERROR",error:y});}};c();let C=setInterval(c,iy);return m(true),()=>{clearInterval(C),m(false);}},[e,t,o]),useEffect(()=>{if(!o||!r)return;let w=async()=>{try{await ic({deposit_wallet_id:r},t);}catch{}};w();let c=setInterval(w,sy);return ()=>clearInterval(c)},[o,r,t]),{executions:i,isPolling:l}}var Fd=(e,t)=>`${t}:${e}`;function aa({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:u,chainPickerBorderTopRightRadius:h}){let{colors:S,fonts:g,components:b}=D(),[w,c]=useState(false),[C,y]=useState(false),f=b.card,d=t?e.find(k=>k.symbol===t):void 0,T=d?.chains||[],_=r?T.find(k=>Fd(k.chain_id,k.chain_type)===r):void 0,x={backgroundColor:f.backgroundColor,borderRadius:f.borderRadius,borderWidth:f.borderWidth||1,borderColor:f.borderColor};return jsxs(View,{style:Qe.row,children:[jsxs(View,{style:Qe.col,children:[jsx(Text,{style:[Qe.label,{color:f.labelColor,fontFamily:g.medium}],children:i}),jsxs(TouchableOpacity,{style:[Qe.selectButton,x],onPress:()=>!a&&e.length>0&&c(true),activeOpacity:.7,disabled:a||e.length===0,children:[a?jsx(Text,{style:[Qe.placeholder,{color:f.subtitleColor,fontFamily:g.regular}],children:"Loading..."}):d?jsxs(View,{style:Qe.selectedItem,children:[jsx(Image,{source:{uri:J(ge(d,"png"))},style:Qe.icon}),jsx(Text,{style:[Qe.selectedText,{color:f.titleColor,fontFamily:g.medium}],numberOfLines:1,children:d.symbol})]}):jsx(Text,{style:[Qe.placeholder,{color:f.subtitleColor,fontFamily:g.regular}],children:"Select receive token"}),jsx(Pt,{size:16,color:f.actionColor,strokeWidth:2})]})]}),jsxs(View,{style:Qe.col,children:[jsx(Text,{style:[Qe.label,{color:f.labelColor,fontFamily:g.medium}],children:s}),jsxs(TouchableOpacity,{style:[Qe.selectButton,x,(!d||T.length===0)&&Qe.disabled],onPress:()=>!a&&d&&T.length>0&&y(true),activeOpacity:.7,disabled:a||!d||T.length===0,children:[_?jsxs(View,{style:Qe.selectedItem,children:[jsx(Image,{source:{uri:J(ge(_,"png"))},style:Qe.icon}),jsx(Text,{style:[Qe.selectedText,{color:f.titleColor,fontFamily:g.medium}],numberOfLines:1,children:_.chain_name})]}):jsx(Text,{style:[Qe.placeholder,{color:f.subtitleColor,fontFamily:g.regular}],children:"Chain"}),jsx(Pt,{size:16,color:f.actionColor,strokeWidth:2})]})]}),jsxs(ct,{visible:w,onClose:()=>c(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:l,borderTopRightRadius:m,children:[jsxs(View,{style:Qe.pickerHeader,children:[jsx(View,{style:Qe.pickerHeaderSpacer}),jsx(Text,{style:[Qe.pickerTitle,{color:S.foreground,fontFamily:g.medium}],children:"Select Token"}),jsx(TouchableOpacity,{style:Qe.pickerHeaderClose,onPress:()=>c(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:S.foregroundMuted,strokeWidth:2})})]}),jsx(BottomSheetFlatList,{data:e,keyExtractor:k=>k.symbol,contentContainerStyle:Qe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:k})=>jsxs(TouchableOpacity,{style:[Qe.pickerItem,{backgroundColor:k.symbol===t?S.cardHover:"transparent"}],onPress:()=>{o(k.symbol),c(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:J(ge(k,"png"))},style:Qe.pickerIcon}),jsx(Text,{style:[Qe.pickerItemText,{color:S.foreground,fontFamily:g.medium}],children:k.symbol}),jsx(Text,{style:[Qe.pickerItemSub,{color:S.foregroundMuted,fontFamily:g.regular}],children:k.name}),k.symbol===t&&jsx(qe,{size:18,color:S.primary,strokeWidth:2.5})]})})]}),jsxs(ct,{visible:C,onClose:()=>y(false),closeOnBackdropPress:true,showHandle:true,heightPercent:.6,maxHeightPercent:.9,borderTopLeftRadius:u,borderTopRightRadius:h,children:[jsxs(View,{style:Qe.pickerHeader,children:[jsx(View,{style:Qe.pickerHeaderSpacer}),jsx(Text,{style:[Qe.pickerTitle,{color:S.foreground,fontFamily:g.medium}],children:"Select Chain"}),jsx(TouchableOpacity,{style:Qe.pickerHeaderClose,onPress:()=>y(false),hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:S.foregroundMuted,strokeWidth:2})})]}),jsx(BottomSheetFlatList,{data:T,keyExtractor:k=>Fd(k.chain_id,k.chain_type),contentContainerStyle:Qe.listContent,showsVerticalScrollIndicator:false,renderItem:({item:k})=>{let I=Fd(k.chain_id,k.chain_type);return jsxs(TouchableOpacity,{style:[Qe.pickerItem,{backgroundColor:I===r?S.cardHover:"transparent"}],onPress:()=>{n(I),y(false);},activeOpacity:.7,children:[jsx(Image,{source:{uri:J(ge(k,"png"))},style:Qe.pickerIcon}),jsx(Text,{style:[Qe.pickerItemText,{color:S.foreground,fontFamily:g.medium}],children:k.chain_name}),I===r&&jsx(qe,{size:18,color:S.primary,strokeWidth:2.5})]})}})]})]})}var Qe=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 Dd(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 Yo({queryKey:["unifold","verifyRecipientAddress",t??null,r??null,o??null,s,a],queryFn:()=>nc({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 uy(e){if(e===null)return "< 1 min";let t=Math.ceil(e/60);return t<60?`< ${t} min`:`< ${Math.ceil(t/60)} hr`}function py(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 my(e,t){return e===0?"0":e.toFixed(t).replace(/\.?0+$/,"")}function Dl({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:l,selectedChain:m,balanceData:u,isLoadingBalance:h,minimumWithdrawAmountUsd:S,estimatedProcessingTime:g,maxSlippagePercent:b,priceImpactPercent:w,canWithdraw:c,onDepositWalletCreation:C,onWithdraw:y,onWithdrawError:f,onWithdrawSubmitted:d,onViewTracker:T}){let _="https://unifold.io/terms",x="https://unifold.io/support",{colors:k,fonts:I,components:A}=D(),[V,F]=useState(s||""),[P,W]=useState(""),[$,fe]=useState(false),[Ke,Fe]=useState(null),[G,Se]=useState(false),[he,Ie]=useState(""),Ge=useRef(null);useEffect(()=>{F(s||""),W(""),Fe(null);},[s]);let ke=V.trim();useEffect(()=>{let de=setTimeout(()=>Ie(ke),500);return ()=>clearTimeout(de)},[ke]);let{data:te,isLoading:Te,error:st}=Dd({chainType:m?.chain_type,chainId:m?.chain_id,tokenAddress:m?.token_address,recipientAddress:he,publishableKey:e,enabled:he.length>5&&!!m}),We=ke!==he,Ye=useMemo(()=>!ke||ke.length<=5||We||Te?null:st?"Invalid address":te&&!te.valid?te.failure_code==="account_not_found"?`Account not found on ${m?.chain_name}`:te.failure_code==="not_opted_in"?`Recipient hasn't opted in to ${l?.symbol} on ${m?.chain_name}`:"Invalid address":null,[ke,We,Te,st,te,m,l]),Ae=!We&&!!te?.valid&&!Ye,Ee=useMemo(()=>u?.exchangeRate?parseFloat(u.exchangeRate):0,[u]),Me=useMemo(()=>u?.balanceHuman?parseFloat(u.balanceHuman):0,[u]),pe=n||u?.symbol||"TOKEN",X=u?.decimals??6,be=useMemo(()=>{let de=parseFloat(P);return !de||de<=0?0:de},[P]),pt=useMemo(()=>{let de=parseFloat(P);return !de||de<=0?0:de*Ee},[P,Ee]),z=useCallback(async()=>{try{let et=await Mm("expo-clipboard").getStringAsync();et&&(F(et.trim()),Fe(null));}catch{}},[]),E=useCallback(()=>{Me<=0||W(u?.balanceHuman??"0");},[Me,u]),se=S!==null&&pt>0&&pt<S,oe=be>0&&Me>0&&be>Me,ve=ke.length>0&&P.trim().length>0&&be>0&&Ae&&!se&&!oe&&!!u,xt=useCallback(async()=>{if(!(!l||!m||!ve||!c)){fe(true),Fe(null);try{let de=await C({destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,recipientAddress:ke}),et=py(be,X),xr=my(be,X),_t={sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:pe,sourceTokenIconUrl:i,destinationChainType:m.chain_type,destinationChainId:m.chain_id,destinationTokenAddress:m.token_address,destinationTokenSymbol:l.symbol,destinationChainName:m.chain_name,destinationTokenIconUrl:l?J(ge(l,"png")):void 0,amount:xr,amountBaseUnit:et,submittedAt:new Date,withdrawIntentAddress:de.address,recipientAddress:ke};await y(_t),d(_t);}catch(de){let et=de instanceof Error?de.message:"Withdrawal failed. Please try again.",xr=et.length>120?"Withdrawal failed. Please try again.":et;Fe(xr),f?.({message:et,error:de,code:"WITHDRAW_FAILED"});}finally{fe(false);}}},[l,m,ve,c,ke,t,r,o,pe,i,P,Me,u,be,X,pt,C,y,f,d]),ce=A.input,ae=A.card,ze=A.button,Yt=Ye?k.error:ce.borderColor,mt=useMemo(()=>$?"Processing...":oe?"Insufficient balance":se?`Minimum $${S?.toFixed(2)}`:Ke?"Withdrawal failed \u2014 try again":"Withdraw",[$,oe,se,S,Ke]);return jsxs(View,{style:$e.container,children:[jsxs(View,{children:[jsxs(View,{style:$e.labelRow,children:[jsx(Text,{style:[$e.label,{color:ae.labelColor,fontFamily:I.medium}],children:"Recipient address"}),(We||Te)&&ke.length>5?jsx(ActivityIndicator,{size:"small",color:k.foregroundMuted}):jsx(TouchableOpacity,{onPress:z,activeOpacity:.6,hitSlop:{top:8,bottom:8,left:8,right:8},children:jsx($d,{size:16,color:k.foregroundMuted,strokeWidth:1.75})})]}),jsx(View,{style:[$e.inputRow,{backgroundColor:ce.backgroundColor,borderRadius:ce.borderRadius,borderWidth:ce.borderWidth,borderColor:Yt}],children:jsx(TextInput,{style:[$e.textInput,{color:ce.textColor,fontFamily:I.regular}],placeholder:"Enter wallet address",placeholderTextColor:ce.placeholderColor,value:V,onChangeText:de=>{F(de),Fe(null);},autoCapitalize:"none",autoCorrect:false,returnKeyType:"done",onSubmitEditing:()=>Ge.current?.focus()})}),Ye?jsx(Text,{style:[$e.errorText,{color:k.error,fontFamily:I.regular}],children:Ye}):null]}),jsxs(View,{children:[jsxs(Text,{style:[$e.label,{color:ae.labelColor,fontFamily:I.medium,paddingBottom:8}],children:["Amount",S!=null&&S>0&&jsx(Text,{style:{color:k.warning,fontFamily:I.regular},children:` ($${S.toFixed(2)} min)`})]}),jsxs(View,{style:[$e.amountRow,{backgroundColor:ce.backgroundColor,borderRadius:ce.borderRadius,borderWidth:ce.borderWidth,borderColor:ce.borderColor}],children:[jsx(TextInput,{ref:Ge,style:[$e.amountInput,{color:ce.textColor,fontFamily:I.regular}],placeholder:"0.00",placeholderTextColor:ce.placeholderColor,value:P,onChangeText:de=>{(de===""||/^\d*\.?\d*$/.test(de))&&(W(de),Fe(null));},keyboardType:"decimal-pad",returnKeyType:"done"}),jsx(Text,{style:[$e.unitLabel,{color:k.foregroundMuted,fontFamily:I.medium}],children:pe}),jsx(TouchableOpacity,{style:[$e.maxButton,{backgroundColor:`${k.primary}20`}],onPress:E,activeOpacity:.7,children:jsx(Text,{style:[$e.maxText,{color:k.primary,fontFamily:I.medium}],children:"Max"})})]})]}),jsxs(View,{style:[$e.detailsCard,{marginTop:24,backgroundColor:ae.backgroundColor,borderRadius:ae.borderRadius,borderWidth:ae.borderWidth||1,borderColor:ae.borderColor}],children:[jsx(TouchableOpacity,{style:$e.detailsToggle,onPress:()=>Se(!G),activeOpacity:.7,children:jsxs(View,{style:$e.detailsRow,children:[jsx(View,{style:[$e.detailIcon,{backgroundColor:ae.iconBackgroundColor,borderRadius:ae.iconContainerBorderRadius}],children:jsx(bo,{size:12,color:ae.iconColor,strokeWidth:2})}),jsxs(Text,{style:[$e.detailsLabel,{color:ae.titleColor,fontFamily:I.regular}],children:["Processing time:"," ",jsx(Text,{style:{fontFamily:I.medium},children:uy(g)})]}),jsx(View,{style:{transform:[{rotate:G?"180deg":"0deg"}]},children:jsx(Pt,{size:16,color:ae.actionColor,strokeWidth:2})})]})}),G&&jsxs(View,{style:$e.detailsExpanded,children:[jsxs(View,{style:$e.detailsRow,children:[jsx(View,{style:[$e.detailIcon,{backgroundColor:ae.iconBackgroundColor,borderRadius:ae.iconContainerBorderRadius}],children:jsx(fn,{size:12,color:ae.iconColor,strokeWidth:2})}),jsxs(Text,{style:[$e.detailsLabel,{color:ae.titleColor,fontFamily:I.regular}],children:["Slippage:"," ",jsxs(Text,{style:{fontFamily:I.medium},children:["Auto \u2022 ",(b??.25).toFixed(2),"%"]})]})]}),jsxs(View,{style:$e.detailsRow,children:[jsx(View,{style:[$e.detailIcon,{backgroundColor:ae.iconBackgroundColor,borderRadius:ae.iconContainerBorderRadius}],children:jsx(mn,{size:12,color:ae.iconColor,strokeWidth:2})}),jsxs(Text,{style:[$e.detailsLabel,{color:ae.titleColor,fontFamily:I.regular}],children:["Price impact:"," ",jsxs(Text,{style:{fontFamily:I.medium},children:[(w??0).toFixed(2),"%"]})]})]})]})]}),Ke&&jsx(Text,{style:[$e.errorText,{color:k.error,fontFamily:I.regular,textAlign:"center"}],children:Ke}),jsxs(View,{style:$e.withdrawRow,children:[jsxs(TouchableOpacity,{style:[$e.withdrawButton,{backgroundColor:ze.primaryBackground,borderRadius:ze.borderRadius,borderWidth:ze.borderWidth,borderColor:ze.borderColor,opacity:!ve||!c||$?.5:1}],onPress:xt,disabled:!ve||!c||$,activeOpacity:.8,children:[$&&jsx(ActivityIndicator,{size:"small",color:ze.primaryText}),jsx(Text,{style:[$e.withdrawButtonText,{color:ze.primaryText,fontFamily:I.medium}],children:mt})]}),jsxs(View,{style:$e.footerRow,children:[jsxs(TouchableOpacity,{style:$e.historyLink,onPress:T,activeOpacity:.7,children:[jsx(bo,{size:14,color:k.foregroundMuted,strokeWidth:2}),jsx(Text,{style:[$e.historyText,{color:k.foregroundMuted,fontFamily:I.regular}],children:"Withdrawal history"})]}),jsxs(View,{style:$e.legalLinks,children:[jsx(TouchableOpacity,{onPress:()=>Linking.openURL(_),activeOpacity:.7,children:jsx(Text,{style:[$e.legalText,{color:k.foregroundMuted,fontFamily:I.regular}],children:"Terms"})}),jsx(Text,{style:[$e.legalSeparator,{color:k.foregroundMuted,fontFamily:I.regular}],children:"|"}),jsx(TouchableOpacity,{onPress:()=>Linking.openURL(x),activeOpacity:.7,children:jsx(Text,{style:[$e.legalText,{color:k.foregroundMuted,fontFamily:I.regular}],children:"Help"})})]})]})]})]})}var $e=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 gy(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 yy(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function Bl({execution:e,onPress:t}){let{colors:r,fonts:o,components:n}=D(),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=J(ge(e.destination_token_metadata,"png")||Ht("/icons/tokens/png/usdc.png")),u=s?"Withdrawal Failed":i?"Withdrawal Processing":"Withdrawal Completed",h=gy(e.created_at||new Date().toISOString()),S=yy(e.source_amount_usd);return jsxs(Gt,{cardTokens:a,onPress:t,contentStyle:ln.container,children:[jsxs(View,{style:ln.iconContainer,children:[jsx(Image,{source:{uri:m},style:ln.tokenIcon}),jsx(View,{style:[ln.statusBadge,{backgroundColor:l,borderColor:a.backgroundColor}],children:s?jsx(Ss,{size:12,color:"#FFFFFF",strokeWidth:2.5}):i?jsx(ha,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(qe,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:ln.textContainer,children:[jsx(Text,{style:[ln.title,{color:a.titleColor,fontFamily:o.medium}],children:u}),jsx(Text,{style:[ln.dateTime,{color:a.subtitleColor,fontFamily:o.regular}],children:h})]}),jsxs(View,{style:ln.rightContainer,children:[jsx(Text,{style:[ln.amount,{color:a.textRightColor,fontFamily:o.medium}],children:S}),jsx(Vr,{size:20,color:a.actionColor,strokeWidth:2})]})]})}var ln=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 Bd(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 Rm(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 Cy(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 Im(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function vm(e){return !e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`}function la({label:e,value:t,isLast:r}){let{fonts:o,components:n}=D(),a=n.card;return jsxs(Fragment,{children:[jsxs(View,{style:Be.detailRow,children:[jsx(Text,{style:[Be.detailLabel,{color:a.subtitleColor,fontFamily:o.regular}],children:e}),jsx(Text,{style:[Be.detailValue,{color:a.titleColor,fontFamily:o.regular}],children:t})]}),!r&&jsx(View,{style:[Be.divider,{backgroundColor:a.borderColor}]})]})}function Ad({execution:e,txInfo:t,onClose:r,onViewHistory:o,onBack:n,onHeaderClose:a}){let{colors:i,fonts:s,components:l}=D(),[m,u]=useState([]),[h,S]=useState(!!n),g=l.card,b=l.button,w=l.header,c=l.container;useEffect(()=>{oc().then(fe=>u(fe.data)).catch(()=>{});},[]),useEffect(()=>{S(!!n);},[e?.id]);let C=e?e.status==="pending"||e.status==="waiting"||e.status==="delayed":false,y=e?e.status==="failed"||e.status==="refunded":false,f=y?i.error:C?i.warning:i.success,d=y?"Failed":C?"Processing":"Completed",T=e?.destination_token_metadata?J(ge(e.destination_token_metadata,"png")):t.destinationTokenIconUrl?J(t.destinationTokenIconUrl):J(Ht("/icons/tokens/png/usdc.png")),_=e?.created_at?Bd(e.created_at):t.submittedAt?Bd(t.submittedAt.toISOString()):Bd(new Date().toISOString()),x=e?`${Rm(e.source_amount_base_unit,e.source_token_metadata?.decimals)} ${Im(e.source_currency)}`:`${t.amount} ${t.sourceTokenSymbol}`,k=e?`${Rm(e.destination_amount_base_unit,e.destination_token_metadata?.decimals)} ${Im(e.destination_currency)}`:`${t.amount} ${t.destinationTokenSymbol}`,I=e?Cy(e.source_amount_usd,e.source_amount_base_unit):"$0.00",A=e?ka(m,e.source_chain_type,e.source_chain_id):t.sourceChainId,V=e?ka(m,e.destination_chain_type,e.destination_chain_id):t.destinationChainName??t.destinationChainId,F=e?.transaction_hash,P=e?.explorer_url,W=e?.destination_transaction_hashes?.[0],$=e?.destination_explorer_url;return jsxs(BottomSheetScrollView,{style:Be.scroll,contentContainerStyle:Be.container,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:Be.headerRow,children:[n?jsx(TouchableOpacity,{onPress:n,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Ri,{size:22,color:w.buttonColor,strokeWidth:2})}):jsx(View,{style:Be.headerSpacer}),jsx(Text,{style:[Be.headerTitle,{color:w.titleColor,fontFamily:s.medium}],children:"Withdrawal Details"}),n?jsx(View,{style:Be.headerSpacer}):jsx(TouchableOpacity,{onPress:a??r,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(tt,{size:20,color:w.buttonColor,strokeWidth:2})})]}),jsxs(View,{style:Be.iconContainer,children:[jsx(Image,{source:{uri:T},style:Be.tokenIcon}),jsx(View,{style:[Be.statusBadge,{backgroundColor:f}],children:y?jsx(Ss,{size:10,color:"#FFFFFF",strokeWidth:3}):C?jsx(View,{style:Be.spinnerDot}):jsx(qe,{size:10,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Be.statusRow,children:[jsx(View,{style:[Be.statusDot,{backgroundColor:f}]}),jsx(Text,{style:[Be.statusText,{color:f,fontFamily:s.medium}],children:d})]}),jsx(Text,{style:[Be.dateText,{color:c.subtitleColor,fontFamily:s.regular}],children:_}),jsxs(View,{style:[Be.detailsCard,{backgroundColor:g.backgroundColor,borderRadius:g.borderRadius,borderWidth:g.borderWidth??1,borderColor:g.borderColor}],children:[jsx(la,{label:"Amount Sent",value:x}),jsx(la,{label:"Amount Received",value:k}),jsx(la,{label:"USD Value",value:I}),jsx(la,{label:"Source Network",value:A}),jsx(la,{label:"Destination Network",value:V,isLast:true})]}),jsxs(TouchableOpacity,{style:Be.moreDetailsRow,onPress:()=>S(fe=>!fe),activeOpacity:.7,children:[jsx(Text,{style:[Be.moreDetailsText,{color:c.actionTitle,fontFamily:s.regular}],children:h?"See less":n?"See more":"See more details"}),h?jsx(wo,{size:16,color:c.actionColor,strokeWidth:2}):jsx(Pt,{size:16,color:c.actionColor,strokeWidth:2})]}),h&&jsx(View,{style:[Be.detailsCard,{backgroundColor:g.backgroundColor,borderRadius:g.borderRadius,borderWidth:g.borderWidth??1,borderColor:g.borderColor}],children:F&&P?jsxs(Fragment,{children:[jsxs(TouchableOpacity,{style:Be.txRow,onPress:()=>Linking.openURL(P),activeOpacity:.7,children:[jsx(Text,{style:[Be.txLabel,{color:g.subtitleColor,fontFamily:s.regular}],children:"Withdrawal Tx"}),jsx(Text,{style:[Be.txHash,{color:g.titleColor,fontFamily:s.regular}],children:vm(F)}),jsx(Co,{size:14,color:g.actionColor,strokeWidth:2})]}),!C&&W&&$&&jsxs(Fragment,{children:[jsx(View,{style:[Be.divider,{backgroundColor:g.borderColor}]}),jsxs(TouchableOpacity,{style:Be.txRow,onPress:()=>Linking.openURL($),activeOpacity:.7,children:[jsx(Text,{style:[Be.txLabel,{color:g.subtitleColor,fontFamily:s.regular}],children:"Completion Tx"}),jsx(Text,{style:[Be.txHash,{color:g.titleColor,fontFamily:s.regular}],children:vm(W)}),jsx(Co,{size:14,color:g.actionColor,strokeWidth:2})]})]})]}):jsx(View,{style:Be.detailRow,children:jsx(Text,{style:[Be.detailLabel,{color:g.subtitleColor,fontFamily:s.regular}],children:"Transaction details not yet available"})})}),!n&&jsxs(View,{style:Be.buttonRow,children:[jsx(TouchableOpacity,{style:[Be.button,Be.halfButton,{backgroundColor:b.secondaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Be.buttonText,{color:b.secondaryText,fontFamily:s.medium}],children:"Withdrawal History"})}),jsx(TouchableOpacity,{style:[Be.button,Be.halfButton,{backgroundColor:b.primaryBackground,borderRadius:b.borderRadius,borderWidth:b.borderWidth,borderColor:b.borderColor}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Be.buttonText,{color:b.primaryText,fontFamily:s.medium}],children:"Close"})})]})]})}var Be=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 Pm(e){return e.length<=12?e:`${e.slice(0,6)}...${e.slice(-4)}`}function Wl({txInfo:e,executions:t,onClose:r,onViewTracker:o}){let{colors:n,fonts:a,components:i}=D(),s=t.length>0?t[t.length-1]:null,l=s?.status==="succeeded",m=s?.status==="failed",u={borderRadius:i.button.borderRadius,borderWidth:i.button.borderWidth,borderColor:i.button.borderColor};return l?jsxs(View,{style:Ct.container,children:[jsx(TouchableOpacity,{style:Ct.closeButton,onPress:r,children:jsx(tt,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Ct.iconRing,{backgroundColor:n.successBackground}],children:jsx(qe,{size:32,color:n.success,strokeWidth:2.5})}),jsx(Text,{style:[Ct.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Sent"}),jsxs(Text,{style:[Ct.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",Pm(e.recipientAddress)]}),jsxs(View,{style:Ct.buttonRow,children:[jsx(TouchableOpacity,{style:[Ct.button,Ct.halfButton,u,{backgroundColor:i.button.secondaryBackground}],onPress:o,activeOpacity:.8,children:jsx(Text,{style:[Ct.buttonText,{color:i.button.secondaryText,fontFamily:a.medium}],children:"History"})}),jsx(TouchableOpacity,{style:[Ct.button,Ct.halfButton,u,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Ct.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]})]}):m?jsxs(View,{style:Ct.container,children:[jsx(TouchableOpacity,{style:Ct.closeButton,onPress:r,children:jsx(tt,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(View,{style:[Ct.iconRing,{backgroundColor:n.errorBackground}],children:jsx(tt,{size:32,color:n.error,strokeWidth:2.5})}),jsx(Text,{style:[Ct.title,{color:n.foreground,fontFamily:a.medium}],children:"Withdrawal Failed"}),jsx(Text,{style:[Ct.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:"Something went wrong. Please try again."}),jsx(TouchableOpacity,{style:[Ct.button,Ct.fullButton,u,{backgroundColor:i.button.primaryBackground}],onPress:r,activeOpacity:.8,children:jsx(Text,{style:[Ct.buttonText,{color:i.button.primaryText,fontFamily:a.medium}],children:"Close"})})]}):jsxs(View,{style:Ct.container,children:[jsx(TouchableOpacity,{style:Ct.closeButton,onPress:r,children:jsx(tt,{size:20,color:i.header.buttonColor,strokeWidth:2})}),jsx(ht,{size:80,strokeWidth:4,iconSize:68,gradientFrom:n.primary,gradientTo:n.primary,children:e.sourceTokenIconUrl?jsx(Image,{source:{uri:J(e.sourceTokenIconUrl)},style:Ct.tokenIconFill}):jsx(View,{style:[Ct.tokenIconFill,{backgroundColor:n.cardHover}]})}),jsx(Text,{style:[Ct.title,{color:n.foreground,fontFamily:a.medium,paddingTop:16}],children:"Checking Withdrawal"}),jsxs(Text,{style:[Ct.subtitle,{color:n.foregroundMuted,fontFamily:a.regular}],children:[e.amount," ",e.sourceTokenSymbol," to"," ",Pm(e.recipientAddress)]})]})}var Ct=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 _y(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:J(ge(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:J(ge(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 Om=(e,t)=>`${t}:${e}`;function Ry(){let{colors:e}=D(),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 Ml({visible:e,onClose:t,publishableKey:r,externalUserId:o,senderAddress:n,recipientAddress:a,modalTitle:i="Withdraw Crypto",onWithdraw:s,onWithdrawSuccess:l,onWithdrawError:m,heightPercent:u=.94,sheetBorderRadius:h,sourceChainType:S,sourceChainId:g,sourceTokenAddress:b,sourceTokenSymbol:w,sourceChainName:c,sourceTokenIconUrl:C}){let{colors:y,fonts:f}=D(),[d,T]=useState("form"),[_,x]=useState(S),[k,I]=useState(g),[A,V]=useState(b),[F,P]=useState(w),[W,$]=useState(c),[fe,Ke]=useState(C),[Fe,G]=useState(null),[Se,he]=useState(null),[Ie,Ge]=useState(null),[ke,te]=useState(),[Te,st]=useState([]),[We,Ye]=useState(null),[Ae,Ee]=useState("form"),Me=useRef(new Animated.Value(Dimensions.get("window").width)).current,pe=useRef(null),X=!!_&&!!k&&!!A,{data:be,isLoading:pt}=Ol(r,e&&d==="form"),z=be?.data??[],{data:E,isLoading:se}=vd({sourceChainType:_,sourceChainId:k,sourceTokenAddress:A,sourceTokenSymbol:F,publishableKey:r,enabled:e&&X&&d==="form"}),{data:oe,isLoading:ve}=Pd({address:n,chainType:_,chainId:k,tokenAddress:A,publishableKey:r,enabled:e&&X}),{executions:xt}=Od({userId:o,publishableKey:r,depositWalletId:ke,enabled:!!ke&&e,onWithdrawSuccess:l,onWithdrawError:m});useEffect(()=>{if(!e||d!=="tracker")return;let ne=false;return No(o,r,"withdraw").then(O=>{ne||st(O.data);}).catch(console.error),()=>{ne=true;}},[e,d,o,r]),useEffect(()=>{e&&(pe.current&&(clearTimeout(pe.current),pe.current=null),T("form"),x(S),I(g),V(b),P(w),$(c),Ke(C),G(null),he(null),Ge(null),te(void 0),st([]),Ye(null),Ee("form"),Me.setValue(Dimensions.get("window").width));},[e]),useEffect(()=>()=>{pe.current&&clearTimeout(pe.current);},[]),useEffect(()=>{fe||E?.iconUrl&&Ke(E.iconUrl);},[E?.iconUrl,fe]),useEffect(()=>{W||E?.chainName&&$(E.chainName);},[E?.chainName,W]),useEffect(()=>{d==="confirming"&&xt.length>0&&T("details");},[d,xt]);let ce=useCallback(()=>{t(),pe.current=setTimeout(()=>{T("form"),x(S),I(g),V(b),P(w),$(c),Ke(C),G(null),he(null),Ge(null),te(void 0),st([]),Ye(null),Ee("form"),pe.current=null;},300);},[t,S,g,b,w,c,C]),ae=useCallback(ne=>{let O=z.find(ft=>ft.symbol===ne);O&&(G(O),O.chains.length>0&&he(O.chains[0]));},[z]),ze=useCallback(ne=>{if(!Fe)return;let O=Fe.chains.find(ft=>Om(ft.chain_id,ft.chain_type)===ne);O&&he(O);},[Fe]),Yt=useCallback(async ne=>{let O=await Uo({external_user_id:o,destination_chain_type:ne.destinationChainType,destination_chain_id:ne.destinationChainId,destination_token_address:ne.destinationTokenAddress,recipient_address:ne.recipientAddress,action_type:"withdraw"},r),ft=Ho(O.data,_??"");if(!ft)throw new Error(`No deposit wallet found for chain type: ${_}`);return te(ft.id),{id:ft.id,address:ft.address}},[o,r,_]),mt=useCallback(ne=>{Ge(ne),T("confirming");},[]),de=useCallback(ne=>{Ye(ne),Me.setValue(Dimensions.get("window").width),Animated.timing(Me,{toValue:0,duration:280,useNativeDriver:true}).start();},[Me]),et=useCallback(()=>{Animated.timing(Me,{toValue:Dimensions.get("window").width,duration:250,useNativeDriver:true}).start(()=>Ye(null));},[Me]),xr=pt||se,_t=E?.isSupported??null,io=d==="confirming"?"Withdrawal Status":i,Or=h?.globalBorderTopLeftRadius,ir=h?.globalBorderTopRightRadius,$t=h?.main?.borderTopLeftRadius??Or,xe=h?.main?.borderTopRightRadius??ir,at=h?.tokenSelector?.borderTopLeftRadius??Or,j=h?.tokenSelector?.borderTopRightRadius??ir,re=h?.chainSelector?.borderTopLeftRadius??Or,_e=h?.chainSelector?.borderTopRightRadius??ir,ue=(()=>{if(d!=="form"||!X||ve||!oe)return;let ne=F||oe.symbol,O=oe.balanceUsd;if(O!=null){let un=`$${parseFloat(O).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`;return ne?`Balance: ${un} ${ne}`:`Balance: ${un}`}let ft=oe.balanceHuman;if(!(!ft||ft==="0"))return ne?`Balance: ${ft} ${ne}`:`Balance: ${ft}`})();return jsx(ct,{visible:e,onClose:ce,closeOnBackdropPress:false,enablePanDownToClose:d==="tracker"||d==="form",showHandle:d==="tracker"||d==="form",heightPercent:d==="confirming"?.3:d==="details"?.7:d==="tracker"?.6:u,maxHeightPercent:d==="tracker"?.9:void 0,borderTopLeftRadius:$t,borderTopRightRadius:xe,children:d==="confirming"&&Ie?jsx(Wl,{txInfo:Ie,executions:xt,onClose:ce,onViewTracker:()=>{Ee("confirming"),T("tracker");}}):d==="details"&&Ie?jsx(Ad,{execution:xt.length>0?xt[xt.length-1]:null,txInfo:Ie,onClose:ce,onViewHistory:()=>{Ee("details"),T("tracker");},onHeaderClose:()=>T("form")}):d==="tracker"?jsxs(View,{style:Ao.trackerContainer,children:[jsx(kr,{title:"Withdrawal History",onClose:()=>T(Ae)}),Te.length===0?jsx(View,{style:Ao.emptyState,children:jsx(Text,{style:[Ao.emptyText,{color:y.foregroundMuted,fontFamily:f.regular}],children:"No withdrawals to track yet"})}):jsx(BottomSheetFlatList,{data:Te,keyExtractor:ne=>ne.id,contentContainerStyle:Ao.listContent,showsVerticalScrollIndicator:false,renderItem:({item:ne})=>jsx(Bl,{execution:ne,onPress:()=>de(ne)})}),We&&jsx(Animated.View,{style:[Ao.historyDetailOverlay,{backgroundColor:y.background,transform:[{translateX:Me}]}],children:jsx(Ad,{execution:We,txInfo:_y(We),onClose:ce,onBack:et,onViewHistory:et})})]}):jsxs(Fragment,{children:[jsx(kr,{title:io,subtitle:ue,onClose:ce}),xr?jsx(Ry,{}):_t===false?jsxs(View,{style:Ao.unsupportedContainer,children:[jsx(Text,{style:[Ao.unsupportedTitle,{color:y.foreground,fontFamily:f.medium}],children:"Unsupported Token"}),jsx(Text,{style:[Ao.unsupportedMessage,{color:y.foregroundMuted,fontFamily:f.regular}],children:E?.errorMessage})]}):jsx(Iy,{publishableKey:r,sourceChainType:_??"",sourceChainId:k??"",sourceTokenAddress:A??"",sourceTokenSymbol:F,sourceChainName:W,sourceTokenIconUrl:fe,recipientAddressProp:a,destinationTokens:z,selectedToken:Fe,selectedChain:Se,selectedChainKey:Se?Om(Se.chain_id,Se.chain_type):null,onTokenChange:ae,onChainChange:ze,tokensLoading:pt,balanceData:oe??null,isLoadingBalance:ve,sourceValidation:E??null,onDepositWalletCreation:Yt,onWithdraw:s,onWithdrawError:m,onWithdrawSubmitted:mt,onViewTracker:()=>{Ee("form"),T("tracker");},tokenSelectorLeft:at,tokenSelectorRight:j,chainSelectorLeft:re,chainSelectorRight:_e})]})})}function Iy({publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,destinationTokens:l,selectedToken:m,selectedChain:u,selectedChainKey:h,onTokenChange:S,onChainChange:g,tokensLoading:b,balanceData:w,isLoadingBalance:c,sourceValidation:C,onDepositWalletCreation:y,onWithdraw:f,onWithdrawError:d,onWithdrawSubmitted:T,onViewTracker:_,tokenSelectorLeft:x,tokenSelectorRight:k,chainSelectorLeft:I,chainSelectorRight:A}){return jsx(KeyboardAvoidingView,{behavior:Platform.OS==="ios"?"padding":void 0,style:{flex:1},children:jsxs(BottomSheetScrollView,{style:{flex:1,paddingTop:16},contentContainerStyle:Ao.scrollContent,keyboardShouldPersistTaps:"handled",showsVerticalScrollIndicator:false,children:[jsx(View,{style:Ao.doubleInputWrapper,children:jsx(aa,{tokens:l,selectedTokenSymbol:m?.symbol??null,selectedChainKey:h,onTokenChange:S,onChainChange:g,isLoading:b,tokenPickerBorderTopLeftRadius:x,tokenPickerBorderTopRightRadius:k,chainPickerBorderTopLeftRadius:I,chainPickerBorderTopRightRadius:A})}),jsx(Dl,{publishableKey:e,sourceChainType:t,sourceChainId:r,sourceTokenAddress:o,sourceTokenSymbol:n,sourceChainName:a,sourceTokenIconUrl:i,recipientAddressProp:s,selectedToken:m,selectedChain:u,balanceData:w,isLoadingBalance:c,minimumWithdrawAmountUsd:C?.minimumAmountUsd??null,estimatedProcessingTime:C?.estimatedProcessingTime??null,maxSlippagePercent:C?.maxSlippagePercent??null,priceImpactPercent:C?.priceImpactPercent??null,canWithdraw:true,onDepositWalletCreation:y,onWithdraw:f,onWithdrawError:d,onWithdrawSubmitted:T,onViewTracker:_})]})})}var Ao=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 Vm=createContext(null);function Ay({children:e,publishableKey:t,config:r}){let[o]=useState(()=>new Nc({defaultOptions:{queries:{retry:1,staleTime:3e5}}})),[n,a]=useState(false),[i,s]=useState(null),[l,m]=useState(false),[u,h]=useState(null),S=useColorScheme(),g=useRef(false);g.current||(ba({publishableKey:t}),g.current=true);let b=useMemo(()=>{let P=r?.appearance||"dark";return P==="auto"?S==="dark"?"dark":"light":P},[r?.appearance,S]);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.'),ba({publishableKey:t});},[t]),useEffect(()=>()=>{c.current&&clearTimeout(c.current),_.current&&clearTimeout(_.current);},[]);let w=useRef(null),c=useRef(null),C=useCallback(P=>{c.current&&(clearTimeout(c.current),c.current=null),w.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),w.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),w.current=null);let W=new Promise(($,fe)=>{w.current={resolve:$,reject:fe};});return s(P),a(true),W},[]),y=useCallback(()=>{w.current&&(w.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),w.current=null),a(false),c.current=setTimeout(()=>{s(null),c.current=null;},200);},[]),f=useCallback(P=>{i?.onSuccess&&i.onSuccess(P),w.current&&(w.current.resolve(P),w.current=null);},[i]),d=useCallback(P=>{console.error("[UnifoldProvider] Deposit error:",P),i?.onError&&i.onError(P),w.current&&(w.current.reject(P),w.current=null);},[i]),T=useRef(null),_=useRef(null),x=useRef(void 0),k=useCallback(P=>{_.current&&(clearTimeout(_.current),_.current=null),T.current&&(console.warn("[UnifoldProvider] A withdrawal is already in progress. Cancelling previous withdrawal."),T.current.reject({message:"Withdrawal cancelled - new withdrawal started",code:"WITHDRAW_SUPERSEDED"}),T.current=null);let W=new Promise(($,fe)=>{T.current={resolve:$,reject:fe};});return x.current=P.onClose,h(P),m(true),W},[]),I=useCallback(()=>{T.current&&(T.current.reject({message:"Withdrawal cancelled by user",code:"WITHDRAW_CANCELLED"}),T.current=null),x.current?.(),x.current=void 0,m(false),_.current=setTimeout(()=>{h(null),_.current=null;},200);},[]),A=useCallback(P=>{u?.onSuccess&&u.onSuccess(P),T.current&&(T.current.resolve(P),T.current=null);},[u]),V=useCallback(P=>{console.error("[UnifoldProvider] Withdraw error:",P),u?.onError&&u.onError(P),T.current&&(T.current.reject(P),T.current=null);},[u]),F=useMemo(()=>({publishableKey:t,beginDeposit:C,closeDeposit:y,beginWithdraw:k,closeWithdraw:I}),[t,C,y,k,I]);return jsx(qc,{client:o,children:jsx(Vm.Provider,{value:F,children:jsxs(vi,{mode:b,accentColor:r?.accentColor,theme:r?.theme,fontFamily:r?.fontFamily,fonts:r?.fonts,components:r?.components,children:[e,i&&jsx(Pl,{visible:n,onClose:y,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?ju():void 0,onDepositSuccess:f,onDepositError:d,theme:b,sheetBorderRadius:r?.sheetBorderRadius}),u&&jsx(Ml,{visible:l,onClose:I,publishableKey:t,externalUserId:u.externalUserId,senderAddress:u.senderAddress,recipientAddress:u.recipientAddress,sourceChainType:u.sourceChainType,sourceChainId:u.sourceChainId,sourceTokenAddress:u.sourceTokenAddress,sourceTokenSymbol:u.sourceTokenSymbol,onWithdraw:u.withdraw,onWithdrawSuccess:A,onWithdrawError:V,sheetBorderRadius:r?.sheetBorderRadius?{globalBorderTopLeftRadius:r.sheetBorderRadius.globalBorderTopLeftRadius,globalBorderTopRightRadius:r.sheetBorderRadius.globalBorderTopRightRadius,tokenSelector:r.sheetBorderRadius.tokenSelector,chainSelector:r.sheetBorderRadius.chainSelector}:void 0})]})})})}function Ey(){let e=useContext(Vm);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
3
+ export{Fa as AmountScreen,ct as BottomSheet,Da as KYCWizardScreen,Ha as OnrampScreen,Na as StripeOnramp,Hu as StripeOnrampPreconfigure,Ay as UnifoldProvider,ge as getPreferredIcon,Ba as getStripePublishableKey,Ta as getSupportedDestinationTokens,J as normalizeIconUrl,ja as registerStripeOnramp,Gd as setDevApiUrl,La as setStripeOnrampApiUrl,Va as setStripeOnrampPublishableKey,na as useAllowedCountry,Aa as useStripeOnramp,D as useTheme,Ey as useUnifold};