@unifold/connect-react-native 0.1.8 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
  import { ThemeMode } from '@unifold/ui-react-native';
4
- export { ThemeMode, setDevApiUrl } from '@unifold/ui-react-native';
4
+ export { AllowedCountryResult, ThemeMode, setDevApiUrl, useAllowedCountry } from '@unifold/ui-react-native';
5
5
 
6
6
  interface UnifoldConnectProviderConfig {
7
7
  publishableKey: string;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ReactNode } from 'react';
3
3
  import { ThemeMode } from '@unifold/ui-react-native';
4
- export { ThemeMode, setDevApiUrl } from '@unifold/ui-react-native';
4
+ export { AllowedCountryResult, ThemeMode, setDevApiUrl, useAllowedCountry } from '@unifold/ui-react-native';
5
5
 
6
6
  interface UnifoldConnectProviderConfig {
7
7
  publishableKey: string;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var react=require('react'),reactNative=require('react-native'),reactQuery=require('@tanstack/react-query'),jsxRuntime=require('react/jsx-runtime'),Z=require('react-native-svg'),Kr=require('react-native-qrcode-svg'),reactNativeWebview=require('react-native-webview');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Z__default=/*#__PURE__*/_interopDefault(Z);var Kr__default=/*#__PURE__*/_interopDefault(Kr);var Oo={background:"#ffffff",foreground:"#0f0f0f",foregroundMuted:"#737373",card:"#f5f5f5",cardHover:"#e5e5e5",border:"#e5e5e5",overlay:"rgba(0, 0, 0, 0.5)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Pr={background:"#0f0f0f",foreground:"#fafafa",foregroundMuted:"#a3a3a3",card:"#262626",cardHover:"#404040",border:"#333333",overlay:"rgba(0, 0, 0, 0.7)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},jo=react.createContext({colors:Oo,isDark:false,mode:"auto"});function ht({children:e,mode:t="auto"}){let o=reactNative.useColorScheme(),n=react.useMemo(()=>{let c;return t==="auto"?c=o==="dark":c=t==="dark",{colors:c?Pr:Oo,isDark:c,mode:t}},[t,o]);return jsxRuntime.jsx(jo.Provider,{value:n,children:e})}function P(){let e=react.useContext(jo);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}var Lr="https://api.unifold.io",Et,Le="pk_test_123",Mt={};function pe(){return typeof __DEV__<"u"&&__DEV__&&Et?Et:Lr}function zt(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.'),Le=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(Et=e.baseUrl),e.defaultConfig&&(Mt=e.defaultConfig);}function No(e){typeof __DEV__<"u"&&__DEV__?(Et=e,console.log(`[Unifold DEV] API URL set to: ${e}`)):console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function Oe(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 ne(e){let t=e.startsWith("/")?e:`/${e}`;return `${pe()}/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+)?/,pe()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${pe()}${e}`:`${pe()}/api/public${e}`:""}async function qo(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||Mt.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Mt.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||Mt.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},n=t||Le;Oe(n);let c=await fetch(`${pe()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!c.ok)throw new Error(`Failed to create deposit address: ${c.statusText}`);return c.json()}async function mt(e,t){return qo(e?{...e,external_user_id:e.external_user_id}:void 0,t)}function yt(e,t){return e.find(o=>o.chain_type===t)}async function wt(e,t){let o=t||Le;Oe(o);let n=await fetch(`${pe()}/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})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}function X(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let o=e.icon_urls.find(n=>n.format===t);return o?o.url:e.icon_url}async function mo(e){let t=e||Le;Oe(t);let o=await fetch(`${pe()}/v1/public/tokens/supported_deposit_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch supported deposit tokens: ${o.statusText}`);return o.json()}async function yo(e,t){let o=t||Le;Oe(o);let n=await fetch(`${pe()}/v1/public/onramps/meld/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to fetch Meld quotes: ${n.statusText}`);return n.json()}async function wo(e,t){let o=t||Le;Oe(o);let n=await fetch(`${pe()}/v1/public/onramps/meld/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to create Meld session: ${n.statusText}`);return n.json()}async function Co(e){let t=e||Le;Oe(t);let o=await fetch(`${pe()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch fiat currencies: ${o.statusText}`);return o.json()}async function xo(e){let t=e||Le;Oe(t);let o=await fetch(`${pe()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch project config: ${o.statusText}`);return o.json()}var{height:nt}=reactNative.Dimensions.get("window");function $({visible:e,onClose:t,children:o,closeOnBackdropPress:n=true,showHandle:c=true,heightPercent:s,noPadding:p=false}){let{colors:C}=P(),f=react.useRef(new reactNative.Animated.Value(nt)).current,r=react.useRef(new reactNative.Animated.Value(0)).current;react.useEffect(()=>{e?(f.setValue(nt),r.setValue(0),reactNative.Animated.parallel([reactNative.Animated.spring(f,{toValue:0,useNativeDriver:true,tension:65,friction:11}),reactNative.Animated.timing(r,{toValue:.5,duration:200,useNativeDriver:true})]).start()):reactNative.Animated.parallel([reactNative.Animated.spring(f,{toValue:nt,useNativeDriver:true,tension:65,friction:11}),reactNative.Animated.timing(r,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,f,r]);let V=()=>{n&&t();};return jsxRuntime.jsx(reactNative.Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxRuntime.jsxs(reactNative.View,{style:je.container,children:[jsxRuntime.jsx(reactNative.TouchableWithoutFeedback,{onPress:V,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[je.backdrop,{backgroundColor:"#000000",opacity:r}]})}),jsxRuntime.jsxs(reactNative.Animated.View,{style:[je.sheet,{backgroundColor:C.background,borderTopLeftRadius:24,borderTopRightRadius:24,transform:[{translateY:f}],...s&&{height:nt*s,maxHeight:nt*s},...p&&{paddingBottom:0}}],children:[c&&jsxRuntime.jsx(reactNative.View,{style:je.handleContainer,children:jsxRuntime.jsx(reactNative.View,{style:[je.handle,{backgroundColor:C.border}]})}),jsxRuntime.jsx(reactNative.View,{style:[je.content,s&&je.contentFlex],children:o})]})]})})}var je=reactNative.StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...reactNative.StyleSheet.absoluteFillObject},sheet:{maxHeight:nt*.9,paddingBottom:reactNative.Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingTop:12,paddingBottom:4},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function bo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(Z.Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function ko({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ct({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function To({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Te({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.Line,{x1:"18",y1:"6",x2:"6",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ne({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(Z.Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function se({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(Z.Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function te({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(Z.Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function qe({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function So({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Path,{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ko({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(Z.Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Jo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function it({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(Z.Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ft({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.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:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _o({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(Z__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(Z.Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(Z.Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ae({title:e,showBack:t=false,showClose:o=true,onBack:n,onClose:c,badge:s}){let{colors:p}=P();return jsxRuntime.jsxs(reactNative.View,{style:ge.header,children:[jsxRuntime.jsx(reactNative.View,{style:ge.leftContainer,children:t&&n?jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:n,style:[ge.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(To,{size:20,color:p.foreground,strokeWidth:2})}):jsxRuntime.jsx(reactNative.View,{style:ge.spacer})}),jsxRuntime.jsxs(reactNative.View,{style:ge.titleContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[ge.title,{color:p.foreground}],children:e}),s&&s.count>0&&jsxRuntime.jsx(reactNative.View,{style:[ge.titleBadge,{backgroundColor:p.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[ge.titleBadgeText,{color:p.foregroundMuted}],children:s.count})})]}),jsxRuntime.jsx(reactNative.View,{style:ge.rightContainer,children:o?jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:c,style:[ge.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(Te,{size:20,color:p.foreground,strokeWidth:2})}):jsxRuntime.jsx(reactNative.View,{style:ge.spacer})})]})}var ge=reactNative.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,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,fontWeight:"500",textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function le({uri:e,width:t,height:o,borderRadius:n=0,borderWidth:c=0,borderColor:s="transparent",backgroundColor:p="transparent",style:C}){let[f,r]=react.useState(false),V=e?.toLowerCase().endsWith(".svg");if(!e)return jsxRuntime.jsx(reactNative.View,{style:[{width:t,height:o,borderRadius:n,backgroundColor:"#374151"},C]});let T={width:t,height:o,borderRadius:n,borderWidth:c,borderColor:s,backgroundColor:p,overflow:"hidden",alignItems:"center",justifyContent:"center",...C},a=t-c*2,D=o-c*2;return f?jsxRuntime.jsx(reactNative.View,{style:[T,{backgroundColor:p||"#374151"}]}):V?jsxRuntime.jsx(reactNative.View,{style:T,children:jsxRuntime.jsx(Z.SvgUri,{uri:e,width:a,height:D,onError:A=>{console.log(`[RemoteIcon] SVG load error for ${e}:`,A),r(true);}})}):jsxRuntime.jsx(reactNative.View,{style:T,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:{width:a,height:D},resizeMode:"contain",onError:A=>{console.log(`[RemoteIcon] Image load error for ${e}:`,A.nativeEvent.error),r(true);}})})}function xt({onPress:e,title:t,subtitle:o,featuredTokens:n}){let{colors:c}=P(),s=n?[...n].sort((p,C)=>p.position-C.position):[];return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Se.container,{backgroundColor:c.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:Se.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[Se.iconContainer,{backgroundColor:c.cardHover}],children:jsxRuntime.jsx(bo,{size:20,color:c.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:Se.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Se.title,{color:c.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[Se.subtitle,{color:c.foregroundMuted}],children:o})]})]}),jsxRuntime.jsx(reactNative.View,{style:Se.rightContent,children:jsxRuntime.jsx(reactNative.View,{style:Se.networkIcons,children:s.map((p,C)=>{let f=p.icon_urls.find(r=>r.format==="png")?.url||p.icon_urls.find(r=>r.format==="svg")?.url;return jsxRuntime.jsx(reactNative.View,{style:[Se.networkIconWrapper,{marginLeft:C===0?0:-6,zIndex:s.length-C}],children:jsxRuntime.jsx(le,{uri:z(f),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:c.card})},p.name)})})})]})}var Se=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,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 kt({onPress:e,title:t,subtitle:o,paymentNetworks:n}){let{colors:c}=P();return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Me.container,{backgroundColor:c.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:Me.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[Me.iconContainer,{backgroundColor:c.cardHover}],children:jsxRuntime.jsx(ko,{size:20,color:c.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:Me.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Me.title,{color:c.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[Me.subtitle,{color:c.foregroundMuted}],children:o})]})]}),jsxRuntime.jsx(reactNative.View,{style:Me.rightContent,children:jsxRuntime.jsx(reactNative.View,{style:Me.paymentIcons,children:n?.map(s=>{let p=s.icon_urls.find(C=>C.format==="png")?.url||s.icon_urls.find(C=>C.format==="svg")?.url;return jsxRuntime.jsx(le,{uri:z(p),width:32,height:20,borderRadius:4},s.name)})})})]})}var Me=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,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 Tt({onPress:e,title:t,subtitle:o,badge:n}){let{colors:c}=P();return jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Ee.container,{backgroundColor:c.card}],children:jsxRuntime.jsxs(reactNative.View,{style:Ee.leftContent,children:[jsxRuntime.jsxs(reactNative.View,{style:[Ee.iconContainer,{backgroundColor:c.cardHover}],children:[jsxRuntime.jsx(Ct,{size:20,color:c.foreground,strokeWidth:2}),n!==void 0&&n>0&&jsxRuntime.jsx(reactNative.View,{style:[Ee.badge,{backgroundColor:c.primary}],children:jsxRuntime.jsx(reactNative.Text,{style:Ee.badgeText,children:n>99?"99+":n})})]}),jsxRuntime.jsxs(reactNative.View,{style:Ee.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Ee.title,{color:c.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[Ee.subtitle,{color:c.foregroundMuted}],children:o})]})]})})}var Ee=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,borderRadius:9,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 Ot({value:e,size:t=180,logoUri:o,logoSize:n=40,logoBackgroundColor:c}){let{colors:s,isDark:p}=P(),C=p?"#1a1a1a":"#ffffff",f=p?"#ffffff":"#000000",r=c||C;return jsxRuntime.jsxs(reactNative.View,{style:[ir.container,{width:t,height:t}],children:[jsxRuntime.jsx(Kr__default.default,{value:e||"placeholder",size:t,backgroundColor:C,color:f,ecl:"H",quietZone:4}),o&&jsxRuntime.jsx(reactNative.View,{style:[ir.logoContainer,{width:n+12,height:n+12,backgroundColor:r,borderRadius:(n+12)/2}],children:jsxRuntime.jsx(le,{uri:o,width:n,height:n,borderRadius:n/2})})]})}var ir=reactNative.StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function ar(e){let t=e.split("/"),o=t[t.length-1];return o&&o.length>10?`${o.slice(0,6)}...${o.slice(-3)}`:o||""}function nn(e){let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],n=e.getDate(),c=e.getFullYear(),s=e.getHours(),p=e.getMinutes(),C=s>=12?"pm":"am";s=s%12,s=s||12;let f=p<10?`0${p}`:p;return `${o} ${n}, ${c} at ${s}:${f}${C}`}function $t({visible:e,status:t,tokenIconUrl:o,explorerUrl:n,completionExplorerUrl:c,date:s,amountUsd:p,onClose:C}){let{colors:f}=P(),r=react.useRef(new reactNative.Animated.Value(0)).current,[V,T]=react.useState(false),a=t==="pending"||t==="waiting"||t==="delayed",D=t==="succeeded";react.useEffect(()=>{if(a&&e){let L=reactNative.Animated.loop(reactNative.Animated.timing(r,{toValue:1,duration:1e3,easing:reactNative.Easing.linear,useNativeDriver:true}));return L.start(),()=>L.stop()}else r.setValue(0);},[a,e,r]);let A=r.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]}),O=()=>{n&&reactNative.Linking.openURL(n);},E=()=>{c&&reactNative.Linking.openURL(c);};return jsxRuntime.jsx($,{visible:e,onClose:C,closeOnBackdropPress:true,showHandle:false,children:jsxRuntime.jsxs(reactNative.View,{style:N.container,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{style:N.closeButton,onPress:C,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(Te,{size:20,color:f.foregroundMuted,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:N.iconContainer,children:[o?jsxRuntime.jsx(reactNative.Image,{source:{uri:z(o)},style:N.tokenIcon}):jsxRuntime.jsx(reactNative.View,{style:[N.tokenIcon,{backgroundColor:f.cardHover}]}),jsxRuntime.jsx(reactNative.View,{style:[N.statusBadge,{backgroundColor:a?"#F97316":"#22C55E"}],children:a?jsxRuntime.jsx(reactNative.Animated.View,{style:{transform:[{rotate:A}]},children:jsxRuntime.jsx(Ft,{size:16,color:"#fff",strokeWidth:2.5})}):jsxRuntime.jsx(te,{size:16,color:"#fff",strokeWidth:3})})]}),jsxRuntime.jsx(reactNative.Text,{style:[N.title,{color:f.foreground}],children:a?"Deposit Processing":"Deposit Complete"}),p!==void 0&&jsxRuntime.jsxs(reactNative.Text,{style:[N.amount,{color:f.foreground}],children:["$",p.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),s&&jsxRuntime.jsx(reactNative.Text,{style:[N.date,{color:f.foregroundMuted}],children:nn(s)}),jsxRuntime.jsx(reactNative.Text,{style:[N.subtitle,{color:f.foregroundMuted}],children:a?"This usually takes less than a minute.":"Your account has been credited successfully!"}),D&&(n||c)&&jsxRuntime.jsxs(reactNative.View,{style:N.detailsSection,children:[jsxRuntime.jsx(reactNative.View,{style:[N.divider,{backgroundColor:f.border}]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:N.detailsToggle,onPress:()=>T(!V),children:[jsxRuntime.jsx(reactNative.Text,{style:[N.detailsToggleText,{color:f.foregroundMuted}],children:V?"See less":"See more details"}),V?jsxRuntime.jsx(it,{size:18,color:f.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(se,{size:18,color:f.foregroundMuted,strokeWidth:2})]}),V&&jsxRuntime.jsxs(reactNative.View,{style:N.txButtonsContainer,children:[n&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[N.txButton,{backgroundColor:f.card,borderColor:f.border}],onPress:O,children:[jsxRuntime.jsx(reactNative.Text,{style:[N.txLabel,{color:f.foreground}],children:"Deposit tx"}),jsxRuntime.jsx(reactNative.Text,{style:[N.txHash,{color:f.foregroundMuted}],children:ar(n)}),jsxRuntime.jsx(qe,{size:16,color:f.foregroundMuted,strokeWidth:2})]}),c&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[N.txButton,{backgroundColor:f.card,borderColor:f.border}],onPress:E,children:[jsxRuntime.jsx(reactNative.Text,{style:[N.txLabel,{color:f.foreground}],children:"Completion tx"}),jsxRuntime.jsx(reactNative.Text,{style:[N.txHash,{color:f.foregroundMuted}],children:ar(c)}),jsxRuntime.jsx(qe,{size:16,color:f.foregroundMuted,strokeWidth:2})]})]})]})]})})}var N=reactNative.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},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"}});var St=(e,t)=>`${t}:${e}`,ln=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function Yt({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:n,destinationChainId:c,destinationTokenAddress:s,onExecutionsChange:p,onDepositSuccess:C,onDepositError:f}){let{colors:r}=P(),[V,T]=react.useState("USDC"),[a,D]=react.useState("solana:mainnet"),[A,O]=react.useState([]),[E,L]=react.useState(true),[I,oe]=react.useState([]),[h,j]=react.useState(true),[G,ee]=react.useState(false),[J,W]=react.useState(false),[de,re]=react.useState(false),[vt,me]=react.useState(false),[Ze,pt]=react.useState([]),[Fe,et]=react.useState(new Map),[He]=react.useState(()=>new Date),[tt,xe]=react.useState(null),[De,Dt]=react.useState(false),[Ve,Vt]=react.useState(null),[uo,be]=react.useState(false),ft=new Map;I.forEach(u=>{u.chains.forEach(x=>{let M=`${x.chain_type}:${x.chain_id}`;ft.has(M)||ft.set(M,x);});});let Pt=Array.from(ft.values()),Rt=ln(a),Lt=Pt.find(u=>u.chain_type===Rt.chainType&&u.chain_id===Rt.chainId)?.chain_type||"ethereum",Pe=yt(A,Lt)?.address||"";react.useEffect(()=>{async function u(){try{j(!0),xe(null);let x=await mo(t);if(oe(x.data),x.data.length>0){let M=x.data[0];if(T(M.symbol),M.chains.length>0){let F=M.chains[0];D(St(F.chain_id,F.chain_type));}}}catch(x){console.error("Error fetching supported tokens:",x),xe("Failed to load supported tokens"),f?.({message:"Failed to load supported tokens",error:x});}finally{j(false);}}u();},[t,f]),react.useEffect(()=>{async function u(){try{L(!0),xe(null);let x=await mt({external_user_id:e,recipient_address:o,destination_chain_type:n,destination_chain_id:c,destination_token_address:s},t);O(x.data);}catch(x){console.error("Error fetching wallets:",x),xe("Failed to load wallets"),f?.({message:"Failed to load wallets",error:x});}finally{L(false);}}u();},[e,o,n,c,s,t,f]),react.useEffect(()=>{if(!e||!He)return;let u=setInterval(async()=>{try{let x=await wt(e,t),M=null;for(let F of x.data){let ue=F.created_at?new Date(F.created_at):null;if(!ue||ue<=He)continue;let Re=Fe.get(F.id);if(!Re){M=F;break}if(["pending","waiting","delayed"].includes(Re)&&F.status==="succeeded"){M=F;break}}if(M){let F=M;pt(ue=>{let Re=ue.findIndex(gt=>gt.id===F.id);if(Re>=0){let gt=[...ue];return gt[Re]=F,gt}else return [...ue,F]}),et(ue=>{let Re=new Map(ue);return Re.set(F.id,F.status),Re}),Vt(F),Dt(!0),F.status==="succeeded"&&C?.({message:"Deposit completed successfully",executionId:F.id}),p?.([...Ze,F]);}}catch(x){console.error("Error polling executions:",x),f?.({message:"Failed to check deposit status",error:x});}},5e3);return ()=>clearInterval(u)},[e,t,He,Fe,Ze,p,C,f]),react.useEffect(()=>{if(!I.length)return;let u=I.find(M=>M.symbol===V);if(!u||u.chains.length===0)return;if(!u.chains.some(M=>St(M.chain_id,M.chain_type)===a)){let M=u.chains[0];D(St(M.chain_id,M.chain_type));}},[V,I,a]);let Ue=I.find(u=>u.symbol===V),Bt=Ue?.chains||[],ke=Bt.find(u=>St(u.chain_id,u.chain_type)===a),fo=async()=>{if(Pe)try{reactNative.Clipboard.setString(Pe),ee(!0),setTimeout(()=>ee(!1),2e3);}catch(u){console.error("Failed to copy:",u);}},Wt=ke?.estimated_price_impact_percent??0,ot=ke?.max_slippage_percent??.25,go=ke?.minimum_deposit_amount_usd??3;if(h)return jsxRuntime.jsxs(reactNative.View,{style:i.loadingContainer,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:r.primary}),jsxRuntime.jsx(reactNative.Text,{style:[i.loadingText,{color:r.foregroundMuted}],children:"Loading currencies..."})]});if(tt&&I.length===0)return jsxRuntime.jsxs(reactNative.View,{style:i.errorContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.errorText,{color:r.error}],children:tt}),jsxRuntime.jsx(reactNative.Text,{style:[i.errorHint,{color:r.foregroundMuted}],children:"Please check your network connection and try again."})]});let ho=()=>jsxRuntime.jsxs($,{visible:de,onClose:()=>re(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsxs(reactNative.View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsxRuntime.jsx(reactNative.View,{style:i.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Select Token"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>re(false),style:i.sheetCloseButton,children:jsxRuntime.jsx(Te,{size:20,color:r.foreground,strokeWidth:2})})]}),jsxRuntime.jsx(reactNative.ScrollView,{style:i.sheetList,showsVerticalScrollIndicator:false,children:I.map(u=>jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{T(u.symbol),re(false);},style:[i.sheetItem,{backgroundColor:V===u.symbol?r.card:"transparent"}],children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:z(X(u,"png"))},style:i.sheetItemIcon}),jsxRuntime.jsxs(reactNative.View,{style:i.sheetItemText,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.sheetItemTitle,{color:r.foreground}],children:u.symbol}),jsxRuntime.jsxs(reactNative.Text,{style:[i.sheetItemSubtitle,{color:r.foregroundMuted}],children:[u.chains.length," network",u.chains.length!==1?"s":""," available"]})]}),V===u.symbol&&jsxRuntime.jsx(te,{size:20,color:r.primary,strokeWidth:2})]},u.symbol))})]}),m=()=>jsxRuntime.jsxs($,{visible:vt,onClose:()=>me(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsxs(reactNative.View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsxRuntime.jsx(reactNative.View,{style:i.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Select Network"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>me(false),style:i.sheetCloseButton,children:jsxRuntime.jsx(Te,{size:20,color:r.foreground,strokeWidth:2})})]}),jsxRuntime.jsx(reactNative.ScrollView,{style:i.sheetList,showsVerticalScrollIndicator:false,children:Bt.map(u=>{let x=St(u.chain_id,u.chain_type),M=a===x;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{D(x),me(false);},style:[i.sheetItem,{backgroundColor:M?r.card:"transparent"}],children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:z(X(u,"png"))},style:i.sheetItemIcon}),jsxRuntime.jsxs(reactNative.View,{style:i.sheetItemText,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.sheetItemTitle,{color:r.foreground}],children:u.chain_name}),jsxRuntime.jsxs(reactNative.Text,{style:[i.sheetItemSubtitle,{color:r.foregroundMuted}],children:["Min deposit: $",u.minimum_deposit_amount_usd]})]}),M&&jsxRuntime.jsx(te,{size:20,color:r.primary,strokeWidth:2})]},x)})})]});return jsxRuntime.jsxs(reactNative.View,{style:i.container,children:[jsxRuntime.jsxs(reactNative.View,{style:i.selectorSection,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.selectorLabel,{color:r.foregroundMuted}],children:"Token"}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>re(true),style:[i.selector,{backgroundColor:r.card}],children:[Ue&&jsxRuntime.jsx(reactNative.Image,{source:{uri:z(X(Ue,"png"))},style:i.selectorIcon}),jsxRuntime.jsx(reactNative.Text,{style:[i.selectorText,{color:r.foreground}],children:V}),jsxRuntime.jsx(se,{size:16,color:r.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsxs(reactNative.View,{style:i.selectorSection,children:[jsxRuntime.jsxs(reactNative.Text,{style:[i.selectorLabel,{color:r.foregroundMuted}],children:["Network"," ",jsxRuntime.jsxs(reactNative.Text,{style:i.minDeposit,children:["($",go," min)"]})]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>me(true),style:[i.selector,{backgroundColor:r.card}],children:[ke&&jsxRuntime.jsx(reactNative.Image,{source:{uri:z(X(ke,"png"))},style:i.selectorIcon}),jsxRuntime.jsx(reactNative.Text,{style:[i.selectorText,{color:r.foreground}],numberOfLines:1,children:ke?.chain_name||"Select network"}),jsxRuntime.jsx(se,{size:16,color:r.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsx(reactNative.View,{style:i.qrContainer,children:jsxRuntime.jsx(reactNative.View,{style:[i.qrWrapper,{backgroundColor:r.background,borderColor:r.border}],children:E?jsxRuntime.jsxs(reactNative.View,{style:i.qrLoading,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:r.primary}),jsxRuntime.jsx(reactNative.Text,{style:[i.loadingText,{color:r.foregroundMuted}],children:"Loading..."})]}):Pe?jsxRuntime.jsx(Ot,{value:Pe,size:160,logoUri:z(X(ke,"png")||ne("/icons/networks/png/ethereum.png")),logoSize:40}):jsxRuntime.jsx(reactNative.View,{style:i.qrLoading,children:jsxRuntime.jsx(reactNative.Text,{style:[i.errorText,{color:r.error}],children:"No address available"})})})}),jsxRuntime.jsxs(reactNative.View,{style:i.addressSection,children:[jsxRuntime.jsxs(reactNative.View,{style:i.addressHeader,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.addressLabel,{color:r.foregroundMuted}],children:"Deposit Address"}),G&&jsxRuntime.jsxs(reactNative.View,{style:i.copiedIndicator,children:[jsxRuntime.jsx(te,{size:14,color:r.success,strokeWidth:2}),jsxRuntime.jsx(reactNative.Text,{style:[i.copiedText,{color:r.success}],children:"Copied"})]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:fo,disabled:!Pe||E,activeOpacity:.7,style:[i.addressBox,{backgroundColor:r.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[i.addressText,{color:r.foreground}],numberOfLines:2,children:E?"Loading...":Pe||"No address available"})})]}),jsxRuntime.jsxs(reactNative.View,{style:[i.detailsCard,{backgroundColor:r.card}],children:[jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>W(!J),style:i.detailsHeader,children:[jsxRuntime.jsxs(reactNative.View,{style:i.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(Ct,{size:12,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Processing time:"," ",jsxRuntime.jsx(reactNative.Text,{style:{color:r.foreground},children:"< 1 min"})]})]}),jsxRuntime.jsx(reactNative.View,{style:i.chevronContainer,children:J?jsxRuntime.jsx(it,{size:16,color:r.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(se,{size:16,color:r.foregroundMuted,strokeWidth:2})})]}),J&&jsxRuntime.jsxs(reactNative.View,{style:i.detailsContent,children:[jsxRuntime.jsxs(reactNative.View,{style:i.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(So,{size:12,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Price impact:"," ",jsxRuntime.jsxs(reactNative.Text,{style:{color:r.foreground},children:[Wt.toFixed(2),"%"]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>be(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsxRuntime.jsx(_o,{size:14,color:r.foregroundMuted,strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:i.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(Ko,{size:12,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Max slippage:"," ",jsxRuntime.jsxs(reactNative.Text,{style:{color:r.foreground},children:[ot.toFixed(2),"%"]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>be(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsxRuntime.jsx(_o,{size:14,color:r.foregroundMuted,strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:i.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(Jo,{size:12,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Need help?"," ",jsxRuntime.jsx(reactNative.Text,{style:{color:r.foreground,textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:i.termsContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[i.termsText,{color:r.foregroundMuted}],children:"Terms apply"})}),ho(),m(),jsxRuntime.jsxs($,{visible:uo,onClose:()=>be(false),closeOnBackdropPress:true,showHandle:true,children:[jsxRuntime.jsxs(reactNative.View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsxRuntime.jsx(reactNative.View,{style:i.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Price Impact & Slippage"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>be(false),style:i.sheetCloseButton,children:jsxRuntime.jsx(Te,{size:20,color:r.foreground,strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:i.infoSheetContent,children:[jsxRuntime.jsxs(reactNative.View,{style:[i.infoCard,{backgroundColor:r.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:i.infoCardHeader,children:[jsxRuntime.jsx(reactNative.View,{style:[i.infoCardIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(So,{size:16,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsx(reactNative.Text,{style:[i.infoCardTitle,{color:r.foreground}],children:"Price Impact"}),jsxRuntime.jsxs(reactNative.Text,{style:[i.infoCardValue,{color:r.foreground}],children:[Wt.toFixed(2),"%"]})]}),jsxRuntime.jsx(reactNative.Text,{style:[i.infoCardDescription,{color:r.foregroundMuted}],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."})]}),jsxRuntime.jsxs(reactNative.View,{style:[i.infoCard,{backgroundColor:r.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:i.infoCardHeader,children:[jsxRuntime.jsx(reactNative.View,{style:[i.infoCardIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(Xo,{size:16,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsx(reactNative.Text,{style:[i.infoCardTitle,{color:r.foreground}],children:"Max Slippage"}),jsxRuntime.jsxs(reactNative.Text,{style:[i.infoCardValue,{color:r.foreground}],children:[ot.toFixed(2),"%"]})]}),jsxRuntime.jsx(reactNative.Text,{style:[i.infoCardDescription,{color:r.foregroundMuted}],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."})]})]})]}),Ve&&jsxRuntime.jsx($t,{visible:De,status:Ve.status,tokenIconUrl:Ve.destination_token_metadata?.icon_urls?.find(u=>u.format==="png")?.url||Ve.destination_token_metadata?.icon_url||X(Ue,"png"),explorerUrl:Ve.explorer_url,completionExplorerUrl:Ve.destination_explorer_url,onClose:()=>Dt(false)})]})}var i=reactNative.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,borderRadius:16,borderWidth:1},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:{paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,paddingLeft:8,paddingRight:24},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:{maxHeight:400,paddingTop:8},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 Kt({currency:e,isSelected:t,onSelect:o}){let{colors:n}=P();return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[Ye.container,{backgroundColor:n.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:Ye.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[Ye.iconContainer,{backgroundColor:n.background}],children:jsxRuntime.jsx(reactNative.Image,{source:{uri:z(X(e,"png"))},style:Ye.icon})}),jsxRuntime.jsxs(reactNative.View,{style:Ye.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Ye.name,{color:n.foreground}],children:e.name}),jsxRuntime.jsx(reactNative.Text,{style:[Ye.code,{color:n.foregroundMuted}],children:e.currency_code.toUpperCase()})]})]}),t&&jsxRuntime.jsx(te,{size:16,color:n.foreground,strokeWidth:2})]})}var Ye=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,borderRadius: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 It({title:e,currencies:t,selectedCurrency:o,onSelect:n}){let{colors:c}=P();return t.length===0?null:jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.View,{style:pr.headerContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[pr.title,{color:c.foregroundMuted}],children:e})}),t.map(s=>jsxRuntime.jsx(Kt,{currency:s,isSelected:o.toLowerCase()===s.currency_code.toLowerCase(),onSelect:n},s.currency_code))]})}var pr=reactNative.StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function Xt({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:n,selectedCurrency:c,onSelectCurrency:s}){let{colors:p}=P(),[C,f]=react.useState(""),r=n.map(E=>o.find(L=>L.currency_code.toLowerCase()===E.toLowerCase())).filter(E=>E!==void 0),V=o.filter(E=>!n.includes(E.currency_code.toLowerCase())),T=E=>{if(!C)return E;let L=C.toLowerCase();return E.filter(I=>I.name.toLowerCase().includes(L)||I.currency_code.toLowerCase().includes(L))},a=T(r),D=T(V),A=E=>{s(E),t(false),f("");},O=()=>{t(false),f("");};return jsxRuntime.jsxs($,{visible:e,onClose:O,closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(ae,{title:"Currency",showBack:false,onClose:O}),jsxRuntime.jsx(reactNative.View,{style:Ke.searchContainer,children:jsxRuntime.jsx(reactNative.TextInput,{style:[Ke.searchInput,{backgroundColor:p.card,color:p.foreground}],value:C,onChangeText:f,placeholder:"Search",placeholderTextColor:p.foregroundMuted})}),jsxRuntime.jsx(reactNative.ScrollView,{style:Ke.listContainer,showsVerticalScrollIndicator:false,children:jsxRuntime.jsxs(reactNative.View,{style:Ke.listContent,children:[jsxRuntime.jsx(It,{title:"Popular currencies",currencies:a,selectedCurrency:c,onSelect:A}),a.length>0&&D.length>0&&jsxRuntime.jsx(reactNative.View,{style:Ke.sectionSpacer}),jsxRuntime.jsx(It,{title:"All currencies",currencies:D,selectedCurrency:c,onSelect:A}),a.length===0&&D.length===0&&jsxRuntime.jsx(reactNative.View,{style:Ke.noResultsContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[Ke.noResultsText,{color:p.foregroundMuted}],children:"No currencies found"})})]})})]})}var Ke=reactNative.StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:16,paddingBottom:12},searchInput:{padding:16,borderRadius:12,fontSize:14},listContainer:{height:400,paddingHorizontal:12},listContent:{paddingBottom:24,minHeight:400},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});var Tn=[100,500,1e3];function hr(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 eo({externalUserId:e,publishableKey:t,view:o,onViewChange:n,maxAmountUsd:c=5e4,destinationTokenSymbol:s="USDC",recipientAddress:p,destinationChainType:C,destinationChainId:f,destinationTokenAddress:r,onDepositSuccess:V,onDepositError:T}){let{colors:a}=P(),[D,A]=react.useState("500.00"),[O,E]=react.useState("usd"),[L,I]=react.useState([]),[oe,h]=react.useState(false),[j,G]=react.useState(null),[ee,J]=react.useState("amount"),[W,de]=react.useState(null),[re,vt]=react.useState([]),[me,Ze]=react.useState(true),[pt,Fe]=react.useState(60),[et,He]=react.useState([]),[tt,xe]=react.useState([]),[De,Dt]=react.useState(null),[Ve,Vt]=react.useState(false),[uo,be]=react.useState(false),[ft,Pt]=react.useState(false),[Rt,Uo]=react.useState(null),Lt=o??ee,po=et.find(m=>m.currency_code.toLowerCase()===O.toLowerCase()),Pe=react.useCallback(m=>{J(m),m==="quotes"?n?.(m,L.length):n?.(m);},[L.length,n]);react.useEffect(()=>{async function m(){try{let u=await mt({external_user_id:e,recipient_address:p,destination_chain_type:C,destination_chain_id:f,destination_token_address:r},t);vt(u.data);}catch(u){console.error("Error fetching wallets:",u),G("Failed to load wallet addresses");}finally{Ze(false);}}m();},[e,p,C,f,r,t]),react.useEffect(()=>{async function m(){try{let u=await Co(t);He(u.data),xe(u.preferred||[]);}catch(u){console.error("Error fetching fiat currencies:",u);}}m();},[t]),react.useEffect(()=>{let m=parseFloat(D);if(isNaN(m)||m<=0){I([]);return}if(O.toLowerCase()==="usd"&&m>c){I([]),G(`Maximum amount is ${hr("usd")}${c.toLocaleString()}`);return}let u=setTimeout(()=>{Ue(m);},500);return ()=>clearTimeout(u)},[D,O,c,t]);let Ue=async m=>{h(true),G(null);try{let u={country_code:"US",destination_currency_code:"usdc_polygon",source_amount:m.toString(),source_currency_code:O.toLowerCase()},x=await yo(u,t);if(I(x.data),x.data.length>0){let M=x.data.reduce((F,ue)=>ue.destination_amount>F.destination_amount?ue:F);de(M);}Fe(60);}catch(u){console.error("Failed to fetch quotes:",u),G("Failed to fetch quotes. Please try again."),I([]);}finally{h(false);}};react.useEffect(()=>{if(L.length===0)return;let m=setInterval(()=>{Fe(u=>{if(u<=1){let x=parseFloat(D);return !isNaN(x)&&x>0&&Ue(x),60}return u-1});},1e3);return ()=>clearInterval(m)},[L.length,D]);let Bt=m=>{(/^\d*\.?\d{0,2}$/.test(m)||m==="")&&A(m);},ke=m=>{A(m.toFixed(2));},fo=()=>W?W.destination_amount.toFixed(2):"0.00",Wt=async()=>{if(W)try{let m=yt(re,"ethereum");if(!m?.address){G("Wallet address not available");return}let u={service_provider:W.service_provider,country_code:W.country_code.toUpperCase(),destination_currency_code:W.destination_currency_code,source_currency_code:W.source_currency_code,wallet_address:m.address,source_amount:D},x=await wo(u,t);Dt({provider:W,sourceCurrency:O,sourceAmount:D}),Uo(x.widget_url),Pt(!0);}catch(m){console.error("Failed to create session:",m),G("Failed to start payment flow"),T?.({message:"Failed to start payment flow",error:m});}},ot=hr(O),go=()=>{Pt(false),Pe("onramp"),V?.({message:"Payment flow completed",executionId:De?.sessionId});},ho=()=>jsxRuntime.jsx(Sn,{visible:ft,onClose:go,url:Rt,providerName:W?.service_provider_display_name||"Complete Payment",colors:a});return Lt==="amount"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:d.amountViewContainer,children:[jsxRuntime.jsxs(reactNative.ScrollView,{style:d.scrollContainer,contentContainerStyle:d.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsxRuntime.jsx(reactNative.View,{style:d.currencySelector,children:jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>Vt(true),style:[d.currencyButton,{backgroundColor:a.card}],children:[po&&jsxRuntime.jsx(reactNative.Image,{source:{uri:z(X(po,"png"))},style:d.currencyIcon}),jsxRuntime.jsx(reactNative.Text,{style:[d.currencyText,{color:a.foreground}],children:O.toUpperCase()}),jsxRuntime.jsx(se,{size:16,color:a.foregroundMuted,strokeWidth:2})]})}),jsxRuntime.jsx(Xt,{open:Ve,onOpenChange:Vt,currencies:et,preferredCurrencyCodes:tt,selectedCurrency:O,onSelectCurrency:m=>{E(m.toLowerCase());}}),jsxRuntime.jsxs(reactNative.View,{style:d.amountContainer,children:[jsxRuntime.jsxs(reactNative.View,{style:d.amountInputRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[d.currencySymbol,{color:a.foreground}],children:ot}),jsxRuntime.jsx(reactNative.TextInput,{style:[d.amountInput,{color:a.foreground}],value:D,onChangeText:Bt,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:a.foregroundMuted})]}),oe?jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:a.primary}):jsxRuntime.jsxs(reactNative.Text,{style:[d.usdcPreview,{color:a.foregroundMuted}],children:["\u2248 ",fo()," ",s]})]}),jsxRuntime.jsx(reactNative.View,{style:d.quickAmounts,children:Tn.map(m=>jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>ke(m),style:[d.quickAmountButton,{backgroundColor:a.card},parseFloat(D)===m&&{borderColor:a.primary,borderWidth:2}],children:jsxRuntime.jsxs(reactNative.Text,{style:[d.quickAmountText,{color:a.foreground}],children:[ot,m.toLocaleString()]})},m))}),jsxRuntime.jsxs(reactNative.View,{style:d.providerSection,children:[jsxRuntime.jsxs(reactNative.View,{style:d.providerHeader,children:[jsxRuntime.jsx(reactNative.Text,{style:[d.providerLabel,{color:a.foreground}],children:"Provider"}),L.length>0&&!oe&&jsxRuntime.jsxs(reactNative.Text,{style:[d.refreshText,{color:a.foregroundMuted}],children:["Refreshing in ",pt,"s"]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>be(true),disabled:oe||L.length===0,style:[d.providerButton,{backgroundColor:a.card},(oe||L.length===0)&&d.disabled],children:oe?jsxRuntime.jsxs(reactNative.View,{style:d.providerLoading,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:a.foregroundMuted}),jsxRuntime.jsx(reactNative.Text,{style:[d.loadingText,{color:a.foregroundMuted}],children:"Finding best rates..."})]}):W?jsxRuntime.jsxs(reactNative.View,{style:d.providerContent,children:[jsxRuntime.jsxs(reactNative.View,{style:d.providerInfo,children:[jsxRuntime.jsx(reactNative.Text,{style:[d.autoPickedText,{color:a.foregroundMuted}],children:"Auto-picked for you"}),jsxRuntime.jsxs(reactNative.View,{style:d.providerRow,children:[jsxRuntime.jsx(le,{uri:z(W.icon_url),width:32,height:32,borderRadius:8}),jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.Text,{style:[d.providerName,{color:a.foreground}],children:W.service_provider_display_name}),jsxRuntime.jsxs(reactNative.Text,{style:[d.bestPriceText,{color:a.success}],children:["Best price \u2022 ",W.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsxRuntime.jsx(Ne,{size:20,color:a.foregroundMuted,strokeWidth:2})]}):jsxRuntime.jsx(reactNative.Text,{style:[d.noProviderText,{color:a.foregroundMuted}],children:parseFloat(D)>0?"No providers available":"Enter an amount to see providers"})}),j&&jsxRuntime.jsx(reactNative.Text,{style:[d.errorText,{color:a.error}],children:j})]}),jsxRuntime.jsxs($,{visible:uo,onClose:()=>be(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(ae,{title:"Select Provider",showBack:false,onClose:()=>be(false),badge:L.length>0?{count:L.length}:void 0}),jsxRuntime.jsx(reactNative.ScrollView,{style:d.providerModalList,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(reactNative.View,{style:d.quotesList,children:[...L].sort((m,u)=>u.destination_amount-m.destination_amount).map((m,u)=>{let x=W?.service_provider===m.service_provider,M=u===0;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{de(m),be(false);},style:[d.quoteItem,{backgroundColor:a.card},x&&{borderColor:a.primary,borderWidth:2}],children:[jsxRuntime.jsxs(reactNative.View,{style:d.quoteLeft,children:[jsxRuntime.jsx(le,{uri:z(m.icon_url),width:32,height:32,borderRadius:8}),jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.Text,{style:[d.quoteName,{color:a.foreground}],children:m.service_provider_display_name}),M&&jsxRuntime.jsx(reactNative.Text,{style:[d.bestPriceLabel,{color:a.success}],children:"\u2713 Best price"})]})]}),jsxRuntime.jsxs(reactNative.View,{style:d.quoteRight,children:[jsxRuntime.jsxs(reactNative.Text,{style:[d.quoteAmount,{color:a.foreground}],children:[m.destination_amount.toFixed(2)," USDC"]}),jsxRuntime.jsxs(reactNative.Text,{style:[d.quoteSource,{color:a.foregroundMuted}],children:["Fee: ",ot,m.total_fee.toFixed(2)]})]})]},m.service_provider)})})})]})]}),jsxRuntime.jsx(reactNative.View,{style:[d.continueButtonContainer,{backgroundColor:a.background}],children:jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:Wt,disabled:oe||me||!W||parseFloat(D)<=0,style:[d.continueButton,{backgroundColor:a.primary},(oe||me||!W)&&d.disabledButton],children:jsxRuntime.jsx(reactNative.Text,{style:d.continueButtonText,children:me?"Loading...":"Continue"})})})]}),ho()]}):Lt==="onramp"&&De?jsxRuntime.jsxs(reactNative.View,{style:d.onrampContainer,children:[jsxRuntime.jsx(le,{uri:z(De.provider.icon_url),width:64,height:64,borderRadius:16}),jsxRuntime.jsxs(reactNative.Text,{style:[d.onrampTitle,{color:a.foreground}],children:["Complete transaction with ",De.provider.service_provider_display_name]}),jsxRuntime.jsx(reactNative.Text,{style:[d.onrampSubtitle,{color:a.foregroundMuted}],children:"You can close this modal."}),jsxRuntime.jsxs(reactNative.View,{style:[d.flowDiagram,{backgroundColor:a.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:d.flowStep,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:ne(`/icons/currencies/png/${De.sourceCurrency.toLowerCase()}.png`)},style:d.flowIconImage}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You use"}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowValue,{color:a.foreground}],children:De.sourceCurrency.toUpperCase()})]}),jsxRuntime.jsx(Ne,{size:16,color:a.foregroundMuted,strokeWidth:2}),jsxRuntime.jsxs(reactNative.View,{style:d.flowStep,children:[jsxRuntime.jsxs(reactNative.View,{style:d.flowIconWithBadge,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:ne("/icons/tokens/png/usdc.png")},style:d.flowIconImageNoBadge}),jsxRuntime.jsx(reactNative.Image,{source:{uri:ne("/icons/networks/png/polygon.png")},style:[d.flowNetworkBadge,{borderColor:a.background}]})]}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You buy"}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowValue,{color:a.foreground}],children:"USDC"})]}),jsxRuntime.jsx(Ne,{size:16,color:a.foregroundMuted,strokeWidth:2}),jsxRuntime.jsxs(reactNative.View,{style:d.flowStep,children:[jsxRuntime.jsxs(reactNative.View,{style:d.flowIconWithBadge,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:ne("/icons/tokens/png/usdc.png")},style:d.flowIconImageNoBadge}),jsxRuntime.jsx(reactNative.Image,{source:{uri:ne("/icons/networks/png/polygon.png")},style:[d.flowNetworkBadge,{borderColor:a.background}]})]}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You receive"}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowValue,{color:a.foreground}],children:s})]})]}),jsxRuntime.jsx(reactNative.View,{style:[d.onrampInfoBox,{backgroundColor:a.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[d.onrampInfoText,{color:a.foregroundMuted}],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 Sn({visible:e,onClose:t,url:o,providerName:n,colors:c}){return jsxRuntime.jsxs($,{visible:e,onClose:t,closeOnBackdropPress:false,showHandle:false,heightPercent:.92,noPadding:true,children:[jsxRuntime.jsxs(reactNative.View,{style:Je.header,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:t,style:Je.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(te,{size:20,color:c.foregroundMuted,strokeWidth:2})}),jsxRuntime.jsx(reactNative.Text,{style:[Je.headerTitle,{color:c.foreground}],children:n}),jsxRuntime.jsx(reactNative.View,{style:Je.headerSpacer})]}),o&&jsxRuntime.jsx(reactNative.View,{style:Je.container,children:jsxRuntime.jsx(reactNativeWebview.WebView,{source:{uri:o},style:Je.webView,startInLoadingState:true,renderLoading:()=>jsxRuntime.jsx(reactNative.View,{style:Je.loading,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:c.primary})})})})]})}var Je=reactNative.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"}}),d=reactNative.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,borderRadius: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,borderRadius:8},quickAmountText:{fontSize:14,fontWeight:"500"},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16,borderRadius:12},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},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:24},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{color:"#FFFFFF",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:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12,borderRadius: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},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,borderRadius:7,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,borderRadius:12,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 Vn(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 Pn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function ro({execution:e,onPress:t}){let {colors:o}=P(),n=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let s=z(X(e.destination_token_metadata,"png")||ne("/icons/tokens/png/usdc.png")),p=n?"Deposit Processing":"Deposit Completed",C=Vn(e.created_at||new Date().toISOString()),f=Pn(e.source_amount_usd);return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:t,activeOpacity:.7,style:[ve.container,{backgroundColor:o.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:ve.iconContainer,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:s},style:ve.tokenIcon}),jsxRuntime.jsx(reactNative.View,{style:[ve.statusBadge,{backgroundColor:n?"#EAB308":"#22C55E",borderColor:o.card}],children:n?jsxRuntime.jsx(Ft,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsxRuntime.jsx(te,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxRuntime.jsxs(reactNative.View,{style:ve.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[ve.title,{color:o.foreground}],children:p}),jsxRuntime.jsx(reactNative.Text,{style:[ve.dateTime,{color:o.foregroundMuted}],children:C})]}),jsxRuntime.jsxs(reactNative.View,{style:ve.rightContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[ve.amount,{color:o.foreground}],children:f}),jsxRuntime.jsx(Ne,{size:20,color:o.foregroundMuted,strokeWidth:2})]})]})}var ve=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12,borderRadius:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-2,right:-2,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"}});var{height:Mn}=reactNative.Dimensions.get("window");function Cr(e,t){let o={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||o[e]||e:o[e]||e}function xr(e,t=6){if(!e)return "\u2014";try{let o=Number(e)/Math.pow(10,t);return o===0?"0.00":o>=1?o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function En(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var br=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function kr(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function zn(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 io({visible:e,onClose:t,executions:o,externalUserId:n,publishableKey:c}){let{colors:s}=P(),[p,C]=react.useState(o),[f,r]=react.useState(false),[V,T]=react.useState(null),[a,D]=react.useState(false),A=react.useRef(null);react.useEffect(()=>{if(!e||!n)return;let h=async()=>{r(true);try{let ee=[...(await wt(n,c)).data].sort((J,W)=>{let de=J.created_at?new Date(J.created_at).getTime():0;return (W.created_at?new Date(W.created_at).getTime():0)-de});C(ee);}catch(G){console.error("Failed to fetch executions:",G),C(o);}finally{r(false);}};h();let j=setInterval(h,1e4);return ()=>clearInterval(j)},[e,n,c,o]),react.useEffect(()=>{o.length>0&&C(h=>{let j=new Set(h.map(ee=>ee.id)),G=o.filter(ee=>!j.has(ee.id));return G.length>0?[...G,...h]:h});},[o]),react.useEffect(()=>{e||T(null);},[e]);let O=h=>{T(h);},E=()=>{T(null),D(false);},L=()=>{T(null),t();};return jsxRuntime.jsxs($,{visible:e,onClose:L,closeOnBackdropPress:true,showHandle:false,heightPercent:.6,children:[jsxRuntime.jsx(ae,{title:V?"Deposit Details":"Deposit Tracker",onClose:L,showClose:!V,showBack:!!V,onBack:E}),V?(()=>{if(!V)return null;let h=V,j=h.status==="pending"||h.status==="waiting"||h.status==="delayed",G=h.status==="succeeded",ee=z(X(h.destination_token_metadata,"png")||ne("/icons/tokens/png/usdc.png")),J=h.provider_metadata?.details,W=J?.currencyIn,de=J?.currencyOut;W?.currency?.symbol||"USDC";de?.currency?.symbol||"USDC";let me=xr(h.source_amount_base_unit,h.source_token_metadata?.decimals),Ze=xr(h.destination_amount_base_unit,h.destination_token_metadata?.decimals),pt=En(h.source_amount_usd),Fe=Cr(h.source_chain_type,h.source_chain_id),et=Cr(h.destination_chain_type,h.destination_chain_id),He=()=>{h.explorer_url&&reactNative.Linking.openURL(h.explorer_url);},tt=()=>{h.destination_explorer_url&&reactNative.Linking.openURL(h.destination_explorer_url);};return jsxRuntime.jsxs(reactNative.ScrollView,{ref:A,style:y.scrollContainer,contentContainerStyle:y.detailsContent,showsVerticalScrollIndicator:false,children:[jsxRuntime.jsxs(reactNative.View,{style:y.iconSection,children:[jsxRuntime.jsxs(reactNative.View,{style:y.iconWrapper,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:ee},style:y.tokenIcon}),jsxRuntime.jsx(reactNative.View,{style:[y.statusBadge,{backgroundColor:j?"#EAB308":"#22C55E",borderColor:s.background}],children:j?jsxRuntime.jsx(se,{size:14,color:"#FFFFFF",strokeWidth:2}):jsxRuntime.jsx(te,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:y.statusRow,children:[jsxRuntime.jsx(reactNative.View,{style:[y.statusDot,{backgroundColor:j?"#EAB308":"#22C55E"}]}),jsxRuntime.jsx(reactNative.Text,{style:[y.statusText,{color:s.foreground}],children:j?"Processing":"Completed"})]}),jsxRuntime.jsx(reactNative.Text,{style:[y.dateText,{color:s.foregroundMuted}],children:zn(h.created_at||new Date().toISOString())})]}),jsxRuntime.jsxs(reactNative.View,{style:[y.card,{backgroundColor:s.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Amount Sent"}),jsxRuntime.jsxs(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:[me," ",kr(h.source_currency)]})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Amount Received"}),jsxRuntime.jsxs(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:[Ze," ",kr(h.destination_currency)]})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"USD Value"}),jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:pt})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Source Network"}),jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:Fe})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Destination Network"}),jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:et})]})]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{let xe=!a;D(xe),xe?setTimeout(()=>{A.current?.scrollToEnd({animated:true});},100):A.current?.scrollTo({y:0,animated:true});},style:y.toggleButton,activeOpacity:.7,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.toggleText,{color:s.foregroundMuted}],children:a?"See less":"See more details"}),a?jsxRuntime.jsx(it,{size:14,color:s.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(se,{size:14,color:s.foregroundMuted,strokeWidth:2})]}),a&&jsxRuntime.jsxs(reactNative.View,{style:[y.card,{backgroundColor:s.card}],children:[h.explorer_url&&jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:He,style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Deposit Tx"}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRowRight,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:br(h.transaction_hash)}),jsxRuntime.jsx(qe,{size:14,color:s.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]})]}),h.destination_explorer_url&&G&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:tt,style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Completion Tx"}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRowRight,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:br(h.destination_transaction_hashes[0])}),jsxRuntime.jsx(qe,{size:14,color:s.foregroundMuted,strokeWidth:2})]})]})]})]})})():jsxRuntime.jsx(reactNative.ScrollView,{style:y.scrollContainer,contentContainerStyle:y.scrollContent,showsVerticalScrollIndicator:false,children:p.length===0?jsxRuntime.jsxs(reactNative.View,{style:y.emptyContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.emptyText,{color:s.foregroundMuted}],children:"No deposits yet"}),jsxRuntime.jsx(reactNative.Text,{style:[y.emptySubtext,{color:s.foregroundMuted}],children:"Your deposit history will appear here"})]}):jsxRuntime.jsx(reactNative.View,{style:y.executionsList,children:p.map(h=>jsxRuntime.jsx(ro,{execution:h,onPress:()=>O(h)},h.id))})})]})}var y=reactNative.StyleSheet.create({scrollContainer:{maxHeight:Mn*.7,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:16},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}});var Xe={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function Un({visible:e,onClose:t,externalUserId:o,publishableKey:n,modalTitle:c="Deposit",destinationTokenSymbol:s,recipientAddress:p,destinationChainType:C,destinationChainId:f,destinationTokenAddress:r,hideDepositTracker:V=false,onDepositSuccess:T,onDepositError:a}){let[D,A]=react.useState([]),[O,E]=react.useState(false),[L,I]=react.useState(false),[oe,h]=react.useState(false),[j,G]=react.useState(null),[ee,J]=react.useState("amount");react.useEffect(()=>{e&&!j&&xo(n).then(G).catch(console.error);},[e,j,n]);let W=()=>{t();},de=D.filter(re=>re.status==="pending"||re.status==="waiting").length;return jsxRuntime.jsxs($,{visible:e,onClose:W,closeOnBackdropPress:false,showHandle:false,children:[jsxRuntime.jsx(ae,{title:c,showBack:false,onClose:W}),jsxRuntime.jsxs(reactNative.View,{style:so.optionsContainer,children:[jsxRuntime.jsx(xt,{onPress:()=>I(true),title:Xe.transferCrypto.title,subtitle:Xe.transferCrypto.subtitle,featuredTokens:j?.transfer_crypto?.networks}),jsxRuntime.jsx(kt,{onPress:()=>h(true),title:Xe.depositWithCard.title,subtitle:Xe.depositWithCard.subtitle,paymentNetworks:j?.payment_networks?.networks}),!V&&jsxRuntime.jsx(Tt,{onPress:()=>E(true),title:Xe.depositTracker.title,subtitle:Xe.depositTracker.subtitle,badge:de>0?de:void 0})]}),jsxRuntime.jsx(io,{visible:O,onClose:()=>E(false),executions:D,externalUserId:o,publishableKey:n}),jsxRuntime.jsxs($,{visible:L,onClose:()=>I(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsxRuntime.jsx(ae,{title:Xe.transferCrypto.title,showBack:false,onClose:()=>I(false)}),jsxRuntime.jsx(reactNative.ScrollView,{style:so.transferScrollContainer,contentContainerStyle:so.scrollContent,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(Yt,{externalUserId:o,publishableKey:n,recipientAddress:p,destinationChainType:C,destinationChainId:f,destinationTokenAddress:r,onExecutionsChange:A,onDepositSuccess:T,onDepositError:a})})]}),jsxRuntime.jsxs($,{visible:oe,onClose:()=>{h(false),J("amount");},closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsxRuntime.jsx(ae,{title:`Deposit ${s||"USDC"}`,showBack:ee==="onramp",onBack:()=>J("amount"),onClose:()=>{h(false),J("amount");}}),jsxRuntime.jsx(reactNative.View,{style:so.buyWithCardContainer,children:jsxRuntime.jsx(eo,{externalUserId:o,publishableKey:n,destinationTokenSymbol:s,recipientAddress:p,destinationChainType:C,destinationChainId:f,destinationTokenAddress:r,onDepositSuccess:T,onDepositError:a,view:ee,onViewChange:re=>J(re)})})]})]})}function lo({theme:e="auto",...t}){return jsxRuntime.jsx(ht,{mode:e,children:jsxRuntime.jsx(Un,{...t})})}var so=reactNative.StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1}});reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});reactNative.StyleSheet.create({icon:{backgroundColor:"transparent"}});var Jn=()=>new reactQuery.QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),_r=react.createContext(null);function Xn({children:e,publishableKey:t,config:o}){let[n]=react.useState(()=>Jn()),[c,s]=react.useState(false),[p,C]=react.useState(null),f=reactNative.useColorScheme(),r=react.useRef(false);r.current||(zt({publishableKey:t}),r.current=true);let V=react.useMemo(()=>{let I=o?.appearance||"dark";return I==="auto"?f==="dark"?"dark":"light":I},[o?.appearance,f]);react.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.'),zt({publishableKey:t});},[t]);let T=react.useRef(null),a=react.useRef(null),D=react.useCallback(I=>{console.log("[UnifoldProvider] beginDeposit called with:",I),a.current&&(clearTimeout(a.current),a.current=null),T.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),T.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),T.current=null);let oe=new Promise((h,j)=>{T.current={resolve:h,reject:j};});return C(I),s(true),oe},[]),A=react.useCallback(()=>{T.current&&(T.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),T.current=null),s(false),a.current=setTimeout(()=>{C(null),a.current=null;},200);},[]),O=react.useCallback(I=>{console.log("[UnifoldProvider] Deposit success:",I),p?.onSuccess&&p.onSuccess(I),T.current&&(T.current.resolve(I),T.current=null);},[p]),E=react.useCallback(I=>{console.error("[UnifoldProvider] Deposit error:",I),p?.onError&&p.onError(I),T.current&&(T.current.reject(I),T.current=null);},[p]),L=react.useMemo(()=>({publishableKey:t,beginDeposit:D,closeDeposit:A}),[t,D,A]);return jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:n,children:jsxRuntime.jsx(_r.Provider,{value:L,children:jsxRuntime.jsxs(ht,{mode:V,children:[e,p&&jsxRuntime.jsx(lo,{visible:c,onClose:A,externalUserId:p.externalUserId,publishableKey:t,modalTitle:o?.modalTitle,destinationTokenSymbol:p.destinationTokenSymbol,recipientAddress:p.recipientAddress,destinationChainId:p.destinationChainId,destinationTokenAddress:p.destinationTokenAddress,hideDepositTracker:o?.hideDepositTracker,onDepositSuccess:O,onDepositError:E,theme:V})]})})})}function Zn(){let e=react.useContext(_r);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
2
- exports.UnifoldProvider=Xn;exports.setDevApiUrl=No;exports.useUnifold=Zn;
1
+ 'use strict';var react=require('react'),reactNative=require('react-native'),reactQuery=require('@tanstack/react-query'),jsxRuntime=require('react/jsx-runtime'),X=require('react-native-svg'),rn=require('react-native-qrcode-svg'),reactNativeWebview=require('react-native-webview');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var X__default=/*#__PURE__*/_interopDefault(X);var rn__default=/*#__PURE__*/_interopDefault(rn);var Go={background:"#ffffff",foreground:"#0f0f0f",foregroundMuted:"#737373",card:"#f5f5f5",cardHover:"#e5e5e5",border:"#e5e5e5",overlay:"rgba(0, 0, 0, 0.5)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Er={background:"#0f0f0f",foreground:"#fafafa",foregroundMuted:"#a3a3a3",card:"#262626",cardHover:"#404040",border:"#333333",overlay:"rgba(0, 0, 0, 0.7)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Yo=react.createContext({colors:Go,isDark:false,mode:"auto"});function xt({children:e,mode:t="auto"}){let o=reactNative.useColorScheme(),n=react.useMemo(()=>{let l;return t==="auto"?l=o==="dark":l=t==="dark",{colors:l?Er:Go,isDark:l,mode:t}},[t,o]);return jsxRuntime.jsx(Yo.Provider,{value:n,children:e})}function V(){let e=react.useContext(Yo);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}var Fr="https://api.unifold.io",Ut,Ae="pk_test_123",jt={};function ae(){return typeof __DEV__<"u"&&__DEV__&&Ut?Ut:Fr}function Ot(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.'),Ae=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(Ut=e.baseUrl),e.defaultConfig&&(jt=e.defaultConfig);}function Jo(e){typeof __DEV__<"u"&&__DEV__?(Ut=e,console.log(`[Unifold DEV] API URL set to: ${e}`)):console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function $e(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 ie(e){let t=e.startsWith("/")?e:`/${e}`;return `${ae()}/api/public${t}`}function H(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,ae()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${ae()}${e}`:`${ae()}/api/public${e}`:""}async function Ko(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||jt.destinationChainId||"8453",destination_token_address:e?.destination_token_address||jt.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||jt.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},n=t||Ae;$e(n);let l=await fetch(`${ae()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!l.ok)throw new Error(`Failed to create deposit address: ${l.statusText}`);return l.json()}async function kt(e,t){return Ko(e?{...e,external_user_id:e.external_user_id}:void 0,t)}function bt(e,t){return e.find(o=>o.chain_type===t)}async function Tt(e,t){let o=t||Ae;$e(o);let n=await fetch(`${ae()}/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})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}function te(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let o=e.icon_urls.find(n=>n.format===t);return o?o.url:e.icon_url}async function bo(e){let t=e||Ae;$e(t);let o=await fetch(`${ae()}/v1/public/tokens/supported_deposit_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch supported deposit tokens: ${o.statusText}`);return o.json()}async function To(e,t){let o=t||Ae;$e(o);let n=await fetch(`${ae()}/v1/public/onramps/meld/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to fetch Meld quotes: ${n.statusText}`);return n.json()}async function So(e,t){let o=t||Ae;$e(o);let n=await fetch(`${ae()}/v1/public/onramps/meld/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to create Meld session: ${n.statusText}`);return n.json()}async function _o(e){let t=e||Ae;$e(t);let o=await fetch(`${ae()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch fiat currencies: ${o.statusText}`);return o.json()}async function St(e){let t=e||Ae;$e(t);let o=await fetch(`${ae()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch project config: ${o.statusText}`);return o.json()}async function Io(){let e=await fetch(`${ae()}/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()}var{height:ct}=reactNative.Dimensions.get("window");function Y({visible:e,onClose:t,children:o,closeOnBackdropPress:n=true,showHandle:l=true,heightPercent:s,noPadding:u=false}){let{colors:w}=V(),p=react.useRef(new reactNative.Animated.Value(ct)).current,k=react.useRef(new reactNative.Animated.Value(0)).current;react.useEffect(()=>{e?(p.setValue(ct),k.setValue(0),reactNative.Animated.parallel([reactNative.Animated.spring(p,{toValue:0,useNativeDriver:true,tension:65,friction:11}),reactNative.Animated.timing(k,{toValue:.5,duration:200,useNativeDriver:true})]).start()):reactNative.Animated.parallel([reactNative.Animated.spring(p,{toValue:ct,useNativeDriver:true,tension:65,friction:11}),reactNative.Animated.timing(k,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,p,k]);let r=()=>{n&&t();};return jsxRuntime.jsx(reactNative.Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxRuntime.jsxs(reactNative.View,{style:Qe.container,children:[jsxRuntime.jsx(reactNative.TouchableWithoutFeedback,{onPress:r,children:jsxRuntime.jsx(reactNative.Animated.View,{style:[Qe.backdrop,{backgroundColor:"#000000",opacity:k}]})}),jsxRuntime.jsxs(reactNative.Animated.View,{style:[Qe.sheet,{backgroundColor:w.background,borderTopLeftRadius:24,borderTopRightRadius:24,transform:[{translateY:p}],...s&&{height:ct*s,maxHeight:ct*s},...u&&{paddingBottom:0}}],children:[l&&jsxRuntime.jsx(reactNative.View,{style:Qe.handleContainer,children:jsxRuntime.jsx(reactNative.View,{style:[Qe.handle,{backgroundColor:w.border}]})}),jsxRuntime.jsx(reactNative.View,{style:[Qe.content,s&&Qe.contentFlex],children:o})]})]})})}var Qe=reactNative.StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...reactNative.StyleSheet.absoluteFillObject},sheet:{maxHeight:ct*.9,paddingBottom:reactNative.Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingTop:12,paddingBottom:4},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function vo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(X.Path,{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Do({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.Rect,{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _t({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Vo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.Line,{x1:"19",y1:"12",x2:"5",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function De({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.Line,{x1:"18",y1:"6",x2:"6",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ge({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(X.Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function ce({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(X.Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function oe({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(X.Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ye({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Po({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.Line,{x1:"12",y1:"1",x2:"12",y2:"23",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Path,{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function or({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(X.Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function rr({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function dt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsx(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsxRuntime.jsx(X.Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function qt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.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:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ro({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function nr({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.Path,{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function $t({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxRuntime.jsxs(X__default.default,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsxRuntime.jsx(X.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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntime.jsx(X.Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function de({title:e,showBack:t=false,showClose:o=true,onBack:n,onClose:l,badge:s}){let{colors:u}=V();return jsxRuntime.jsxs(reactNative.View,{style:we.header,children:[jsxRuntime.jsx(reactNative.View,{style:we.leftContainer,children:t&&n?jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:n,style:[we.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(Vo,{size:20,color:u.foreground,strokeWidth:2})}):jsxRuntime.jsx(reactNative.View,{style:we.spacer})}),jsxRuntime.jsxs(reactNative.View,{style:we.titleContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[we.title,{color:u.foreground}],children:e}),s&&s.count>0&&jsxRuntime.jsx(reactNative.View,{style:[we.titleBadge,{backgroundColor:u.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[we.titleBadgeText,{color:u.foregroundMuted}],children:s.count})})]}),jsxRuntime.jsx(reactNative.View,{style:we.rightContainer,children:o?jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:l,style:[we.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(De,{size:20,color:u.foreground,strokeWidth:2})}):jsxRuntime.jsx(reactNative.View,{style:we.spacer})})]})}var we=reactNative.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,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,fontWeight:"500",textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function ue({uri:e,width:t,height:o,borderRadius:n=0,borderWidth:l=0,borderColor:s="transparent",backgroundColor:u="transparent",style:w}){let[p,k]=react.useState(false),r=e?.toLowerCase().endsWith(".svg");if(!e)return jsxRuntime.jsx(reactNative.View,{style:[{width:t,height:o,borderRadius:n,backgroundColor:"#374151"},w]});let T={width:t,height:o,borderRadius:n,borderWidth:l,borderColor:s,backgroundColor:u,overflow:"hidden",alignItems:"center",justifyContent:"center",...w},a=t-l*2,S=o-l*2;return p?jsxRuntime.jsx(reactNative.View,{style:[T,{backgroundColor:u||"#374151"}]}):r?jsxRuntime.jsx(reactNative.View,{style:T,children:jsxRuntime.jsx(X.SvgUri,{uri:e,width:a,height:S,onError:W=>{console.log(`[RemoteIcon] SVG load error for ${e}:`,W),k(true);}})}):jsxRuntime.jsx(reactNative.View,{style:T,children:jsxRuntime.jsx(reactNative.Image,{source:{uri:e},style:{width:a,height:S},resizeMode:"contain",onError:W=>{console.log(`[RemoteIcon] Image load error for ${e}:`,W.nativeEvent.error),k(true);}})})}function It({onPress:e,title:t,subtitle:o,featuredTokens:n}){let{colors:l}=V(),s=n?[...n].sort((u,w)=>u.position-w.position):[];return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Ve.container,{backgroundColor:l.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:Ve.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[Ve.iconContainer,{backgroundColor:l.cardHover}],children:jsxRuntime.jsx(vo,{size:20,color:l.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:Ve.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Ve.title,{color:l.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[Ve.subtitle,{color:l.foregroundMuted}],children:o})]})]}),jsxRuntime.jsx(reactNative.View,{style:Ve.rightContent,children:jsxRuntime.jsx(reactNative.View,{style:Ve.networkIcons,children:s.map((u,w)=>{let p=u.icon_urls.find(k=>k.format==="png")?.url||u.icon_urls.find(k=>k.format==="svg")?.url;return jsxRuntime.jsx(reactNative.View,{style:[Ve.networkIconWrapper,{marginLeft:w===0?0:-6,zIndex:s.length-w}],children:jsxRuntime.jsx(ue,{uri:H(p),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:l.card})},u.name)})})})]})}var Ve=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,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 Dt({onPress:e,title:t,subtitle:o,paymentNetworks:n}){let{colors:l}=V();return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[ze.container,{backgroundColor:l.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:ze.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[ze.iconContainer,{backgroundColor:l.cardHover}],children:jsxRuntime.jsx(Do,{size:20,color:l.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:ze.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[ze.title,{color:l.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[ze.subtitle,{color:l.foregroundMuted}],children:o})]})]}),jsxRuntime.jsx(reactNative.View,{style:ze.rightContent,children:jsxRuntime.jsx(reactNative.View,{style:ze.paymentIcons,children:n?.map(s=>{let u=s.icon_urls.find(w=>w.format==="png")?.url||s.icon_urls.find(w=>w.format==="svg")?.url;return jsxRuntime.jsx(ue,{uri:H(u),width:32,height:20,borderRadius:4},s.name)})})})]})}var ze=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,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 Vt({onPress:e,title:t,subtitle:o,badge:n}){let{colors:l}=V();return jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Fe.container,{backgroundColor:l.card}],children:jsxRuntime.jsxs(reactNative.View,{style:Fe.leftContent,children:[jsxRuntime.jsxs(reactNative.View,{style:[Fe.iconContainer,{backgroundColor:l.cardHover}],children:[jsxRuntime.jsx(_t,{size:20,color:l.foreground,strokeWidth:2}),n!==void 0&&n>0&&jsxRuntime.jsx(reactNative.View,{style:[Fe.badge,{backgroundColor:l.primary}],children:jsxRuntime.jsx(reactNative.Text,{style:Fe.badgeText,children:n>99?"99+":n})})]}),jsxRuntime.jsxs(reactNative.View,{style:Fe.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Fe.title,{color:l.foreground}],children:t}),jsxRuntime.jsx(reactNative.Text,{style:[Fe.subtitle,{color:l.foregroundMuted}],children:o})]})]})})}var Fe=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,borderRadius:9,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 Yt({value:e,size:t=180,logoUri:o,logoSize:n=40,logoBackgroundColor:l}){let{colors:s,isDark:u}=V(),w=u?"#1a1a1a":"#ffffff",p=u?"#ffffff":"#000000",k=l||w;return jsxRuntime.jsxs(reactNative.View,{style:[ur.container,{width:t,height:t}],children:[jsxRuntime.jsx(rn__default.default,{value:e||"placeholder",size:t,backgroundColor:w,color:p,ecl:"H",quietZone:4}),o&&jsxRuntime.jsx(reactNative.View,{style:[ur.logoContainer,{width:n+12,height:n+12,backgroundColor:k,borderRadius:(n+12)/2}],children:jsxRuntime.jsx(ue,{uri:o,width:n,height:n,borderRadius:n/2})})]})}var ur=reactNative.StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function fr(e){let t=e.split("/"),o=t[t.length-1];return o&&o.length>10?`${o.slice(0,6)}...${o.slice(-3)}`:o||""}function pn(e){let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],n=e.getDate(),l=e.getFullYear(),s=e.getHours(),u=e.getMinutes(),w=s>=12?"pm":"am";s=s%12,s=s||12;let p=u<10?`0${u}`:u;return `${o} ${n}, ${l} at ${s}:${p}${w}`}function Zt({visible:e,status:t,tokenIconUrl:o,explorerUrl:n,completionExplorerUrl:l,date:s,amountUsd:u,onClose:w}){let{colors:p}=V(),k=react.useRef(new reactNative.Animated.Value(0)).current,[r,T]=react.useState(false),a=t==="pending"||t==="waiting"||t==="delayed",S=t==="succeeded";react.useEffect(()=>{if(a&&e){let x=reactNative.Animated.loop(reactNative.Animated.timing(k,{toValue:1,duration:1e3,easing:reactNative.Easing.linear,useNativeDriver:true}));return x.start(),()=>x.stop()}else k.setValue(0);},[a,e,k]);let W=k.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]}),j=()=>{n&&reactNative.Linking.openURL(n);},E=()=>{l&&reactNative.Linking.openURL(l);};return jsxRuntime.jsx(Y,{visible:e,onClose:w,closeOnBackdropPress:true,showHandle:false,children:jsxRuntime.jsxs(reactNative.View,{style:$.container,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{style:$.closeButton,onPress:w,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(De,{size:20,color:p.foregroundMuted,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.View,{style:$.iconContainer,children:[o?jsxRuntime.jsx(reactNative.Image,{source:{uri:H(o)},style:$.tokenIcon}):jsxRuntime.jsx(reactNative.View,{style:[$.tokenIcon,{backgroundColor:p.cardHover}]}),jsxRuntime.jsx(reactNative.View,{style:[$.statusBadge,{backgroundColor:a?"#F97316":"#22C55E"}],children:a?jsxRuntime.jsx(reactNative.Animated.View,{style:{transform:[{rotate:W}]},children:jsxRuntime.jsx(qt,{size:16,color:"#fff",strokeWidth:2.5})}):jsxRuntime.jsx(oe,{size:16,color:"#fff",strokeWidth:3})})]}),jsxRuntime.jsx(reactNative.Text,{style:[$.title,{color:p.foreground}],children:a?"Deposit Processing":"Deposit Complete"}),u!==void 0&&jsxRuntime.jsxs(reactNative.Text,{style:[$.amount,{color:p.foreground}],children:["$",u.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),s&&jsxRuntime.jsx(reactNative.Text,{style:[$.date,{color:p.foregroundMuted}],children:pn(s)}),jsxRuntime.jsx(reactNative.Text,{style:[$.subtitle,{color:p.foregroundMuted}],children:a?"This usually takes less than a minute.":"Your account has been credited successfully!"}),S&&(n||l)&&jsxRuntime.jsxs(reactNative.View,{style:$.detailsSection,children:[jsxRuntime.jsx(reactNative.View,{style:[$.divider,{backgroundColor:p.border}]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:$.detailsToggle,onPress:()=>T(!r),children:[jsxRuntime.jsx(reactNative.Text,{style:[$.detailsToggleText,{color:p.foregroundMuted}],children:r?"See less":"See more details"}),r?jsxRuntime.jsx(dt,{size:18,color:p.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(ce,{size:18,color:p.foregroundMuted,strokeWidth:2})]}),r&&jsxRuntime.jsxs(reactNative.View,{style:$.txButtonsContainer,children:[n&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[$.txButton,{backgroundColor:p.card,borderColor:p.border}],onPress:j,children:[jsxRuntime.jsx(reactNative.Text,{style:[$.txLabel,{color:p.foreground}],children:"Deposit tx"}),jsxRuntime.jsx(reactNative.Text,{style:[$.txHash,{color:p.foregroundMuted}],children:fr(n)}),jsxRuntime.jsx(Ye,{size:16,color:p.foregroundMuted,strokeWidth:2})]}),l&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{style:[$.txButton,{backgroundColor:p.card,borderColor:p.border}],onPress:E,children:[jsxRuntime.jsx(reactNative.Text,{style:[$.txLabel,{color:p.foreground}],children:"Completion tx"}),jsxRuntime.jsx(reactNative.Text,{style:[$.txHash,{color:p.foregroundMuted}],children:fr(l)}),jsxRuntime.jsx(Ye,{size:16,color:p.foregroundMuted,strokeWidth:2})]})]})]})]})})}var $=reactNative.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},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"}});var Pt=(e,t)=>`${t}:${e}`,hn=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function oo({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:n,destinationChainId:l,destinationTokenAddress:s,destinationTokenSymbol:u,onExecutionsChange:w,onDepositSuccess:p,onDepositError:k}){let{colors:r}=V(),[T,a]=react.useState("USDC"),[S,W]=react.useState("solana:mainnet"),[j,E]=react.useState([]),[x,L]=react.useState(true),[F,m]=react.useState([]),[G,U]=react.useState(true),[re,ne]=react.useState(false),[P,xe]=react.useState(false),[Ue,ke]=react.useState(false),[be,se]=react.useState(false),[Se,fe]=react.useState([]),[Oe,wt]=react.useState(new Map),[Ne]=react.useState(()=>new Date),[qe,ge]=react.useState(null),[mo,At]=react.useState(false),[_e,yo]=react.useState(null),[rt,nt]=react.useState(false),it=new Map;F.forEach(g=>{g.chains.forEach(R=>{let z=`${R.chain_type}:${R.chain_id}`;it.has(z)||it.set(z,R);});});let wo=Array.from(it.values()),Et=hn(S),zt=wo.find(g=>g.chain_type===Et.chainType&&g.chain_id===Et.chainId)?.chain_type||"ethereum",Ie=bt(j,zt)?.address||"";react.useEffect(()=>{async function g(){try{U(!0),ge(null);let R=await bo(t);if(m(R.data),R.data.length>0){let z=R.data[0];if(a(z.symbol),z.chains.length>0){let O=z.chains[0];W(Pt(O.chain_id,O.chain_type));}}}catch(R){console.error("Error fetching supported tokens:",R),ge("Failed to load supported tokens"),k?.({message:"Failed to load supported tokens",error:R});}finally{U(false);}}g();},[t,k]),react.useEffect(()=>{async function g(){try{L(!0),ge(null);let R=await kt({external_user_id:e,recipient_address:o,destination_chain_type:n,destination_chain_id:l,destination_token_address:s},t);E(R.data);}catch(R){console.error("Error fetching wallets:",R),ge("Failed to load wallets"),k?.({message:"Failed to load wallets",error:R});}finally{L(false);}}g();},[e,o,n,l,s,t,k]),react.useEffect(()=>{if(!e||!Ne)return;let g=setInterval(async()=>{try{let R=await Tt(e,t),z=null;for(let O of R.data){let We=O.created_at?new Date(O.created_at):null;if(!We||We<=Ne)continue;let Me=Oe.get(O.id);if(!Me){z=O;break}if(["pending","waiting","delayed"].includes(Me)&&O.status==="succeeded"){z=O;break}}if(z){let O=z;fe(We=>{let Me=We.findIndex(Ct=>Ct.id===O.id);if(Me>=0){let Ct=[...We];return Ct[Me]=O,Ct}else return [...We,O]}),wt(We=>{let Me=new Map(We);return Me.set(O.id,O.status),Me}),yo(O),At(!0),O.status==="succeeded"&&p?.({message:"Deposit completed successfully",executionId:O.id}),w?.([...Se,O]);}}catch(R){console.error("Error polling executions:",R),k?.({message:"Failed to check deposit status",error:R});}},5e3);return ()=>clearInterval(g)},[e,t,Ne,Oe,Se,w,p,k]),react.useEffect(()=>{if(!F.length)return;let g=F.find(z=>z.symbol===T);if(!g||g.chains.length===0)return;if(!g.chains.some(z=>Pt(z.chain_id,z.chain_type)===S)){let z=g.chains[0];W(Pt(z.chain_id,z.chain_type));}},[T,F,S]);let st=F.find(g=>g.symbol===T),Ft=st?.chains||[],ve=Ft.find(g=>Pt(g.chain_id,g.chain_type)===S),xo=async()=>{if(Ie)try{reactNative.Clipboard.setString(Ie),ne(!0),setTimeout(()=>ne(!1),2e3);}catch(g){console.error("Failed to copy:",g);}},at=ve?.estimated_price_impact_percent??0,Ht=ve?.max_slippage_percent??.25,ko=ve?.minimum_deposit_amount_usd??3;if(G)return jsxRuntime.jsxs(reactNative.View,{style:i.loadingContainer,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:r.primary}),jsxRuntime.jsx(reactNative.Text,{style:[i.loadingText,{color:r.foregroundMuted}],children:"Loading currencies..."})]});if(qe&&F.length===0)return jsxRuntime.jsxs(reactNative.View,{style:i.errorContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.errorText,{color:r.error}],children:qe}),jsxRuntime.jsx(reactNative.Text,{style:[i.errorHint,{color:r.foregroundMuted}],children:"Please check your network connection and try again."})]});let h=()=>jsxRuntime.jsxs(Y,{visible:Ue,onClose:()=>ke(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsxs(reactNative.View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsxRuntime.jsx(reactNative.View,{style:i.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Select Token"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>ke(false),style:i.sheetCloseButton,children:jsxRuntime.jsx(De,{size:20,color:r.foreground,strokeWidth:2})})]}),jsxRuntime.jsx(reactNative.ScrollView,{style:i.sheetList,showsVerticalScrollIndicator:false,children:F.map(g=>jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{a(g.symbol),ke(false);},style:[i.sheetItem,{backgroundColor:T===g.symbol?r.card:"transparent"}],children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:H(te(g,"png"))},style:i.sheetItemIcon}),jsxRuntime.jsxs(reactNative.View,{style:i.sheetItemText,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.sheetItemTitle,{color:r.foreground}],children:g.symbol}),jsxRuntime.jsxs(reactNative.Text,{style:[i.sheetItemSubtitle,{color:r.foregroundMuted}],children:[g.chains.length," network",g.chains.length!==1?"s":""," available"]})]}),T===g.symbol&&jsxRuntime.jsx(oe,{size:20,color:r.primary,strokeWidth:2})]},g.symbol))})]}),A=()=>jsxRuntime.jsxs(Y,{visible:be,onClose:()=>se(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsxs(reactNative.View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsxRuntime.jsx(reactNative.View,{style:i.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Select Network"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>se(false),style:i.sheetCloseButton,children:jsxRuntime.jsx(De,{size:20,color:r.foreground,strokeWidth:2})})]}),jsxRuntime.jsx(reactNative.ScrollView,{style:i.sheetList,showsVerticalScrollIndicator:false,children:Ft.map(g=>{let R=Pt(g.chain_id,g.chain_type),z=S===R;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{W(R),se(false);},style:[i.sheetItem,{backgroundColor:z?r.card:"transparent"}],children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:H(te(g,"png"))},style:i.sheetItemIcon}),jsxRuntime.jsxs(reactNative.View,{style:i.sheetItemText,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.sheetItemTitle,{color:r.foreground}],children:g.chain_name}),jsxRuntime.jsxs(reactNative.Text,{style:[i.sheetItemSubtitle,{color:r.foregroundMuted}],children:["Min deposit: $",g.minimum_deposit_amount_usd]})]}),z&&jsxRuntime.jsx(oe,{size:20,color:r.primary,strokeWidth:2})]},R)})})]});return jsxRuntime.jsxs(reactNative.View,{style:i.container,children:[jsxRuntime.jsxs(reactNative.View,{style:i.selectorSection,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.selectorLabel,{color:r.foregroundMuted}],children:"Token"}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>ke(true),style:[i.selector,{backgroundColor:r.card}],children:[st&&jsxRuntime.jsx(reactNative.Image,{source:{uri:H(te(st,"png"))},style:i.selectorIcon}),jsxRuntime.jsx(reactNative.Text,{style:[i.selectorText,{color:r.foreground}],children:T}),jsxRuntime.jsx(ce,{size:16,color:r.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsxs(reactNative.View,{style:i.selectorSection,children:[jsxRuntime.jsxs(reactNative.Text,{style:[i.selectorLabel,{color:r.foregroundMuted}],children:["Network"," ",jsxRuntime.jsxs(reactNative.Text,{style:i.minDeposit,children:["($",ko," min)"]})]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>se(true),style:[i.selector,{backgroundColor:r.card}],children:[ve&&jsxRuntime.jsx(reactNative.Image,{source:{uri:H(te(ve,"png"))},style:i.selectorIcon}),jsxRuntime.jsx(reactNative.Text,{style:[i.selectorText,{color:r.foreground}],numberOfLines:1,children:ve?.chain_name||"Select network"}),jsxRuntime.jsx(ce,{size:16,color:r.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsx(reactNative.View,{style:i.qrContainer,children:jsxRuntime.jsx(reactNative.View,{style:[i.qrWrapper,{backgroundColor:r.background,borderColor:r.border}],children:x?jsxRuntime.jsxs(reactNative.View,{style:i.qrLoading,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:r.primary}),jsxRuntime.jsx(reactNative.Text,{style:[i.loadingText,{color:r.foregroundMuted}],children:"Loading..."})]}):Ie?jsxRuntime.jsx(Yt,{value:Ie,size:160,logoUri:H(te(ve,"png")||ie("/icons/networks/png/ethereum.png")),logoSize:40}):jsxRuntime.jsx(reactNative.View,{style:i.qrLoading,children:jsxRuntime.jsx(reactNative.Text,{style:[i.errorText,{color:r.error}],children:"No address available"})})})}),jsxRuntime.jsxs(reactNative.View,{style:i.addressSection,children:[jsxRuntime.jsxs(reactNative.View,{style:i.addressHeader,children:[jsxRuntime.jsx(reactNative.Text,{style:[i.addressLabel,{color:r.foregroundMuted}],children:"Deposit Address"}),re&&jsxRuntime.jsxs(reactNative.View,{style:i.copiedIndicator,children:[jsxRuntime.jsx(oe,{size:14,color:r.success,strokeWidth:2}),jsxRuntime.jsx(reactNative.Text,{style:[i.copiedText,{color:r.success}],children:"Copied"})]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:xo,disabled:!Ie||x,activeOpacity:.7,style:[i.addressBox,{backgroundColor:r.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[i.addressText,{color:r.foreground}],numberOfLines:2,children:x?"Loading...":Ie||"No address available"})})]}),jsxRuntime.jsxs(reactNative.View,{style:[i.detailsCard,{backgroundColor:r.card}],children:[jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>xe(!P),style:i.detailsHeader,children:[jsxRuntime.jsxs(reactNative.View,{style:i.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(_t,{size:12,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Processing time:"," ",jsxRuntime.jsx(reactNative.Text,{style:{color:r.foreground},children:"< 1 min"})]})]}),jsxRuntime.jsx(reactNative.View,{style:i.chevronContainer,children:P?jsxRuntime.jsx(dt,{size:16,color:r.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(ce,{size:16,color:r.foregroundMuted,strokeWidth:2})})]}),P&&jsxRuntime.jsxs(reactNative.View,{style:i.detailsContent,children:[jsxRuntime.jsxs(reactNative.View,{style:i.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(Po,{size:12,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Price impact:"," ",jsxRuntime.jsxs(reactNative.Text,{style:{color:r.foreground},children:[at.toFixed(2),"%"]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>nt(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsxRuntime.jsx(Ro,{size:14,color:r.foregroundMuted,strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:i.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(or,{size:12,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Max slippage:"," ",jsxRuntime.jsxs(reactNative.Text,{style:{color:r.foreground},children:[Ht.toFixed(2),"%"]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>nt(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsxRuntime.jsx(Ro,{size:14,color:r.foregroundMuted,strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:i.detailsRow,children:[jsxRuntime.jsx(reactNative.View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(rr,{size:12,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsxs(reactNative.Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Need help?"," ",jsxRuntime.jsx(reactNative.Text,{style:{color:r.foreground,textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{style:i.termsContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[i.termsText,{color:r.foregroundMuted}],children:"Terms apply"})}),h(),A(),jsxRuntime.jsxs(Y,{visible:rt,onClose:()=>nt(false),closeOnBackdropPress:true,showHandle:true,children:[jsxRuntime.jsxs(reactNative.View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsxRuntime.jsx(reactNative.View,{style:i.sheetHeaderSpacer}),jsxRuntime.jsx(reactNative.Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Price Impact & Slippage"}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>nt(false),style:i.sheetCloseButton,children:jsxRuntime.jsx(De,{size:20,color:r.foreground,strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:i.infoSheetContent,children:[jsxRuntime.jsxs(reactNative.View,{style:[i.infoCard,{backgroundColor:r.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:i.infoCardHeader,children:[jsxRuntime.jsx(reactNative.View,{style:[i.infoCardIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(Po,{size:16,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsx(reactNative.Text,{style:[i.infoCardTitle,{color:r.foreground}],children:"Price Impact"}),jsxRuntime.jsxs(reactNative.Text,{style:[i.infoCardValue,{color:r.foreground}],children:[at.toFixed(2),"%"]})]}),jsxRuntime.jsx(reactNative.Text,{style:[i.infoCardDescription,{color:r.foregroundMuted}],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."})]}),jsxRuntime.jsxs(reactNative.View,{style:[i.infoCard,{backgroundColor:r.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:i.infoCardHeader,children:[jsxRuntime.jsx(reactNative.View,{style:[i.infoCardIcon,{backgroundColor:r.cardHover}],children:jsxRuntime.jsx(nr,{size:16,color:r.foreground,strokeWidth:2})}),jsxRuntime.jsx(reactNative.Text,{style:[i.infoCardTitle,{color:r.foreground}],children:"Max Slippage"}),jsxRuntime.jsxs(reactNative.Text,{style:[i.infoCardValue,{color:r.foreground}],children:[Ht.toFixed(2),"%"]})]}),jsxRuntime.jsx(reactNative.Text,{style:[i.infoCardDescription,{color:r.foregroundMuted}],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."})]})]})]}),_e&&jsxRuntime.jsx(Zt,{visible:mo,status:_e.status,tokenIconUrl:_e.destination_token_metadata?.icon_urls?.find(g=>g.format==="png")?.url||_e.destination_token_metadata?.icon_url||te(st,"png"),explorerUrl:_e.explorer_url,completionExplorerUrl:_e.destination_explorer_url,onClose:()=>At(false)})]})}var i=reactNative.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,borderRadius:16,borderWidth:1},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:{paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,paddingLeft:8,paddingRight:24},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:{maxHeight:400,paddingTop:8},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 ro({currency:e,isSelected:t,onSelect:o}){let{colors:n}=V();return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[Ze.container,{backgroundColor:n.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:Ze.leftContent,children:[jsxRuntime.jsx(reactNative.View,{style:[Ze.iconContainer,{backgroundColor:n.background}],children:jsxRuntime.jsx(reactNative.Image,{source:{uri:H(te(e,"png"))},style:Ze.icon})}),jsxRuntime.jsxs(reactNative.View,{style:Ze.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Ze.name,{color:n.foreground}],children:e.name}),jsxRuntime.jsx(reactNative.Text,{style:[Ze.code,{color:n.foregroundMuted}],children:e.currency_code.toUpperCase()})]})]}),t&&jsxRuntime.jsx(oe,{size:16,color:n.foreground,strokeWidth:2})]})}var Ze=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,borderRadius: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 Lt({title:e,currencies:t,selectedCurrency:o,onSelect:n}){let{colors:l}=V();return t.length===0?null:jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.View,{style:wr.headerContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[wr.title,{color:l.foregroundMuted}],children:e})}),t.map(s=>jsxRuntime.jsx(ro,{currency:s,isSelected:o.toLowerCase()===s.currency_code.toLowerCase(),onSelect:n},s.currency_code))]})}var wr=reactNative.StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function io({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:n,selectedCurrency:l,onSelectCurrency:s}){let{colors:u}=V(),[w,p]=react.useState(""),k=n.map(E=>o.find(x=>x.currency_code.toLowerCase()===E.toLowerCase())).filter(E=>E!==void 0),r=o.filter(E=>!n.includes(E.currency_code.toLowerCase())),T=E=>{if(!w)return E;let x=w.toLowerCase();return E.filter(L=>L.name.toLowerCase().includes(x)||L.currency_code.toLowerCase().includes(x))},a=T(k),S=T(r),W=E=>{s(E),t(false),p("");},j=()=>{t(false),p("");};return jsxRuntime.jsxs(Y,{visible:e,onClose:j,closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(de,{title:"Currency",showBack:false,onClose:j}),jsxRuntime.jsx(reactNative.View,{style:et.searchContainer,children:jsxRuntime.jsx(reactNative.TextInput,{style:[et.searchInput,{backgroundColor:u.card,color:u.foreground}],value:w,onChangeText:p,placeholder:"Search",placeholderTextColor:u.foregroundMuted})}),jsxRuntime.jsx(reactNative.ScrollView,{style:et.listContainer,showsVerticalScrollIndicator:false,children:jsxRuntime.jsxs(reactNative.View,{style:et.listContent,children:[jsxRuntime.jsx(Lt,{title:"Popular currencies",currencies:a,selectedCurrency:l,onSelect:W}),a.length>0&&S.length>0&&jsxRuntime.jsx(reactNative.View,{style:et.sectionSpacer}),jsxRuntime.jsx(Lt,{title:"All currencies",currencies:S,selectedCurrency:l,onSelect:W}),a.length===0&&S.length===0&&jsxRuntime.jsx(reactNative.View,{style:et.noResultsContainer,children:jsxRuntime.jsx(reactNative.Text,{style:[et.noResultsText,{color:u.foregroundMuted}],children:"No currencies found"})})]})})]})}var et=reactNative.StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:16,paddingBottom:12},searchInput:{padding:16,borderRadius:12,fontSize:14},listContainer:{height:400,paddingHorizontal:12},listContent:{paddingBottom:24,minHeight:400},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});var Pn=[100,500,1e3];function kr(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 ao({externalUserId:e,publishableKey:t,view:o,onViewChange:n,maxAmountUsd:l=5e4,destinationTokenSymbol:s="USDC",recipientAddress:u,destinationChainType:w,destinationChainId:p,destinationTokenAddress:k,onDepositSuccess:r,onDepositError:T}){let{colors:a}=V(),[S,W]=react.useState("500.00"),[j,E]=react.useState("usd"),[x,L]=react.useState([]),[F,m]=react.useState(false),[G,U]=react.useState(null),[re,ne]=react.useState("amount"),[P,xe]=react.useState(null),[Ue,ke]=react.useState([]),[be,se]=react.useState(true),[Se,fe]=react.useState(60),[Oe,wt]=react.useState([]),[Ne,qe]=react.useState([]),[ge,mo]=react.useState(null),[At,_e]=react.useState(false),[yo,rt]=react.useState(false),[nt,it]=react.useState(false),[wo,Et]=react.useState(null),Co=o??re,zt=Oe.find(h=>h.currency_code.toLowerCase()===j.toLowerCase()),Qo=react.useCallback(h=>{ne(h),h==="quotes"?n?.(h,x.length):n?.(h);},[x.length,n]);react.useEffect(()=>{async function h(){try{let A=await kt({external_user_id:e,recipient_address:u,destination_chain_type:w,destination_chain_id:p,destination_token_address:k},t);ke(A.data);}catch(A){console.error("Error fetching wallets:",A),U("Failed to load wallet addresses");}finally{se(false);}}h();},[e,u,w,p,k,t]),react.useEffect(()=>{async function h(){try{let A=await _o(t);wt(A.data),qe(A.preferred||[]);}catch(A){console.error("Error fetching fiat currencies:",A);}}h();},[t]),react.useEffect(()=>{let h=parseFloat(S);if(isNaN(h)||h<=0){L([]);return}if(j.toLowerCase()==="usd"&&h>l){L([]),U(`Maximum amount is ${kr("usd")}${l.toLocaleString()}`);return}let A=setTimeout(()=>{Ie(h);},500);return ()=>clearTimeout(A)},[S,j,l,t]);let Ie=async h=>{m(true),U(null);try{let A={country_code:"US",destination_currency_code:"usdc_polygon",source_amount:h.toString(),source_currency_code:j.toLowerCase()},g=await To(A,t);if(L(g.data),g.data.length>0){let R=g.data.reduce((z,O)=>O.destination_amount>z.destination_amount?O:z);xe(R);}fe(60);}catch(A){console.error("Failed to fetch quotes:",A),U("Failed to fetch quotes. Please try again."),L([]);}finally{m(false);}};react.useEffect(()=>{if(x.length===0)return;let h=setInterval(()=>{fe(A=>{if(A<=1){let g=parseFloat(S);return !isNaN(g)&&g>0&&Ie(g),60}return A-1});},1e3);return ()=>clearInterval(h)},[x.length,S]);let st=h=>{(/^\d*\.?\d{0,2}$/.test(h)||h==="")&&W(h);},Ft=h=>{W(h.toFixed(2));},ve=()=>P?P.destination_amount.toFixed(2):"0.00",xo=async()=>{if(P)try{let h=bt(Ue,"ethereum");if(!h?.address){U("Wallet address not available");return}let A={service_provider:P.service_provider,country_code:P.country_code.toUpperCase(),destination_currency_code:P.destination_currency_code,source_currency_code:P.source_currency_code,wallet_address:h.address,source_amount:S},g=await So(A,t);mo({provider:P,sourceCurrency:j,sourceAmount:S}),Et(g.widget_url),it(!0);}catch(h){console.error("Failed to create session:",h),U("Failed to start payment flow"),T?.({message:"Failed to start payment flow",error:h});}},at=kr(j),Ht=()=>{it(false),Qo("onramp"),r?.({message:"Payment flow completed",executionId:ge?.sessionId});},ko=()=>jsxRuntime.jsx(Rn,{visible:nt,onClose:Ht,url:wo,providerName:P?.service_provider_display_name||"Complete Payment",colors:a});return Co==="amount"?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs(reactNative.View,{style:d.amountViewContainer,children:[jsxRuntime.jsxs(reactNative.ScrollView,{style:d.scrollContainer,contentContainerStyle:d.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsxRuntime.jsx(reactNative.View,{style:d.currencySelector,children:jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>_e(true),style:[d.currencyButton,{backgroundColor:a.card}],children:[zt&&jsxRuntime.jsx(reactNative.Image,{source:{uri:H(te(zt,"png"))},style:d.currencyIcon}),jsxRuntime.jsx(reactNative.Text,{style:[d.currencyText,{color:a.foreground}],children:j.toUpperCase()}),jsxRuntime.jsx(ce,{size:16,color:a.foregroundMuted,strokeWidth:2})]})}),jsxRuntime.jsx(io,{open:At,onOpenChange:_e,currencies:Oe,preferredCurrencyCodes:Ne,selectedCurrency:j,onSelectCurrency:h=>{E(h.toLowerCase());}}),jsxRuntime.jsxs(reactNative.View,{style:d.amountContainer,children:[jsxRuntime.jsxs(reactNative.View,{style:d.amountInputRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[d.currencySymbol,{color:a.foreground}],children:at}),jsxRuntime.jsx(reactNative.TextInput,{style:[d.amountInput,{color:a.foreground}],value:S,onChangeText:st,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:a.foregroundMuted})]}),F?jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:a.primary}):jsxRuntime.jsxs(reactNative.Text,{style:[d.usdcPreview,{color:a.foregroundMuted}],children:["\u2248 ",ve()," ",s]})]}),jsxRuntime.jsx(reactNative.View,{style:d.quickAmounts,children:Pn.map(h=>jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>Ft(h),style:[d.quickAmountButton,{backgroundColor:a.card},parseFloat(S)===h&&{borderColor:a.primary,borderWidth:2}],children:jsxRuntime.jsxs(reactNative.Text,{style:[d.quickAmountText,{color:a.foreground}],children:[at,h.toLocaleString()]})},h))}),jsxRuntime.jsxs(reactNative.View,{style:d.providerSection,children:[jsxRuntime.jsxs(reactNative.View,{style:d.providerHeader,children:[jsxRuntime.jsx(reactNative.Text,{style:[d.providerLabel,{color:a.foreground}],children:"Provider"}),x.length>0&&!F&&jsxRuntime.jsxs(reactNative.Text,{style:[d.refreshText,{color:a.foregroundMuted}],children:["Refreshing in ",Se,"s"]})]}),jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:()=>rt(true),disabled:F||x.length===0,style:[d.providerButton,{backgroundColor:a.card},(F||x.length===0)&&d.disabled],children:F?jsxRuntime.jsxs(reactNative.View,{style:d.providerLoading,children:[jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"small",color:a.foregroundMuted}),jsxRuntime.jsx(reactNative.Text,{style:[d.loadingText,{color:a.foregroundMuted}],children:"Finding best rates..."})]}):P?jsxRuntime.jsxs(reactNative.View,{style:d.providerContent,children:[jsxRuntime.jsxs(reactNative.View,{style:d.providerInfo,children:[jsxRuntime.jsx(reactNative.Text,{style:[d.autoPickedText,{color:a.foregroundMuted}],children:"Auto-picked for you"}),jsxRuntime.jsxs(reactNative.View,{style:d.providerRow,children:[jsxRuntime.jsx(ue,{uri:H(P.icon_url),width:32,height:32,borderRadius:8}),jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.Text,{style:[d.providerName,{color:a.foreground}],children:P.service_provider_display_name}),jsxRuntime.jsxs(reactNative.Text,{style:[d.bestPriceText,{color:a.success}],children:["Best price \u2022 ",P.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsxRuntime.jsx(Ge,{size:20,color:a.foregroundMuted,strokeWidth:2})]}):jsxRuntime.jsx(reactNative.Text,{style:[d.noProviderText,{color:a.foregroundMuted}],children:parseFloat(S)>0?"No providers available":"Enter an amount to see providers"})}),G&&jsxRuntime.jsx(reactNative.Text,{style:[d.errorText,{color:a.error}],children:G})]}),jsxRuntime.jsxs(Y,{visible:yo,onClose:()=>rt(false),closeOnBackdropPress:true,showHandle:false,children:[jsxRuntime.jsx(de,{title:"Select Provider",showBack:false,onClose:()=>rt(false),badge:x.length>0?{count:x.length}:void 0}),jsxRuntime.jsx(reactNative.ScrollView,{style:d.providerModalList,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(reactNative.View,{style:d.quotesList,children:[...x].sort((h,A)=>A.destination_amount-h.destination_amount).map((h,A)=>{let g=P?.service_provider===h.service_provider,R=A===0;return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{xe(h),rt(false);},style:[d.quoteItem,{backgroundColor:a.card},g&&{borderColor:a.primary,borderWidth:2}],children:[jsxRuntime.jsxs(reactNative.View,{style:d.quoteLeft,children:[jsxRuntime.jsx(ue,{uri:H(h.icon_url),width:32,height:32,borderRadius:8}),jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsx(reactNative.Text,{style:[d.quoteName,{color:a.foreground}],children:h.service_provider_display_name}),R&&jsxRuntime.jsx(reactNative.Text,{style:[d.bestPriceLabel,{color:a.success}],children:"\u2713 Best price"})]})]}),jsxRuntime.jsxs(reactNative.View,{style:d.quoteRight,children:[jsxRuntime.jsxs(reactNative.Text,{style:[d.quoteAmount,{color:a.foreground}],children:[h.destination_amount.toFixed(2)," USDC"]}),jsxRuntime.jsxs(reactNative.Text,{style:[d.quoteSource,{color:a.foregroundMuted}],children:["Fee: ",at,h.total_fee.toFixed(2)]})]})]},h.service_provider)})})})]})]}),jsxRuntime.jsx(reactNative.View,{style:[d.continueButtonContainer,{backgroundColor:a.background}],children:jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:xo,disabled:F||be||!P||parseFloat(S)<=0,style:[d.continueButton,{backgroundColor:a.primary},(F||be||!P)&&d.disabledButton],children:jsxRuntime.jsx(reactNative.Text,{style:d.continueButtonText,children:be?"Loading...":"Continue"})})})]}),ko()]}):Co==="onramp"&&ge?jsxRuntime.jsxs(reactNative.View,{style:d.onrampContainer,children:[jsxRuntime.jsx(ue,{uri:H(ge.provider.icon_url),width:64,height:64,borderRadius:16}),jsxRuntime.jsxs(reactNative.Text,{style:[d.onrampTitle,{color:a.foreground}],children:["Complete transaction with ",ge.provider.service_provider_display_name]}),jsxRuntime.jsx(reactNative.Text,{style:[d.onrampSubtitle,{color:a.foregroundMuted}],children:"You can close this modal."}),jsxRuntime.jsxs(reactNative.View,{style:[d.flowDiagram,{backgroundColor:a.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:d.flowStep,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:ie(`/icons/currencies/png/${ge.sourceCurrency.toLowerCase()}.png`)},style:d.flowIconImage}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You use"}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowValue,{color:a.foreground}],children:ge.sourceCurrency.toUpperCase()})]}),jsxRuntime.jsx(Ge,{size:16,color:a.foregroundMuted,strokeWidth:2}),jsxRuntime.jsxs(reactNative.View,{style:d.flowStep,children:[jsxRuntime.jsxs(reactNative.View,{style:d.flowIconWithBadge,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:ie("/icons/tokens/png/usdc.png")},style:d.flowIconImageNoBadge}),jsxRuntime.jsx(reactNative.Image,{source:{uri:ie("/icons/networks/png/polygon.png")},style:[d.flowNetworkBadge,{borderColor:a.background}]})]}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You buy"}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowValue,{color:a.foreground}],children:"USDC"})]}),jsxRuntime.jsx(Ge,{size:16,color:a.foregroundMuted,strokeWidth:2}),jsxRuntime.jsxs(reactNative.View,{style:d.flowStep,children:[jsxRuntime.jsxs(reactNative.View,{style:d.flowIconWithBadge,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:ie("/icons/tokens/png/usdc.png")},style:d.flowIconImageNoBadge}),jsxRuntime.jsx(reactNative.Image,{source:{uri:ie("/icons/networks/png/polygon.png")},style:[d.flowNetworkBadge,{borderColor:a.background}]})]}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You receive"}),jsxRuntime.jsx(reactNative.Text,{style:[d.flowValue,{color:a.foreground}],children:s})]})]}),jsxRuntime.jsx(reactNative.View,{style:[d.onrampInfoBox,{backgroundColor:a.card}],children:jsxRuntime.jsx(reactNative.Text,{style:[d.onrampInfoText,{color:a.foregroundMuted}],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 Rn({visible:e,onClose:t,url:o,providerName:n,colors:l}){return jsxRuntime.jsxs(Y,{visible:e,onClose:t,closeOnBackdropPress:false,showHandle:false,heightPercent:.92,noPadding:true,children:[jsxRuntime.jsxs(reactNative.View,{style:tt.header,children:[jsxRuntime.jsx(reactNative.TouchableOpacity,{onPress:t,style:tt.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsxRuntime.jsx(oe,{size:20,color:l.foregroundMuted,strokeWidth:2})}),jsxRuntime.jsx(reactNative.Text,{style:[tt.headerTitle,{color:l.foreground}],children:n}),jsxRuntime.jsx(reactNative.View,{style:tt.headerSpacer})]}),o&&jsxRuntime.jsx(reactNative.View,{style:tt.container,children:jsxRuntime.jsx(reactNativeWebview.WebView,{source:{uri:o},style:tt.webView,startInLoadingState:true,renderLoading:()=>jsxRuntime.jsx(reactNative.View,{style:tt.loading,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:l.primary})})})})]})}var tt=reactNative.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"}}),d=reactNative.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,borderRadius: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,borderRadius:8},quickAmountText:{fontSize:14,fontWeight:"500"},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16,borderRadius:12},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},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:24},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{color:"#FFFFFF",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:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12,borderRadius: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},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,borderRadius:7,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,borderRadius:12,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 An(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 En(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function uo({execution:e,onPress:t}){let {colors:o}=V(),n=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let s=H(te(e.destination_token_metadata,"png")||ie("/icons/tokens/png/usdc.png")),u=n?"Deposit Processing":"Deposit Completed",w=An(e.created_at||new Date().toISOString()),p=En(e.source_amount_usd);return jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:t,activeOpacity:.7,style:[Le.container,{backgroundColor:o.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:Le.iconContainer,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:s},style:Le.tokenIcon}),jsxRuntime.jsx(reactNative.View,{style:[Le.statusBadge,{backgroundColor:n?"#EAB308":"#22C55E",borderColor:o.card}],children:n?jsxRuntime.jsx(qt,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsxRuntime.jsx(oe,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxRuntime.jsxs(reactNative.View,{style:Le.textContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Le.title,{color:o.foreground}],children:u}),jsxRuntime.jsx(reactNative.Text,{style:[Le.dateTime,{color:o.foregroundMuted}],children:w})]}),jsxRuntime.jsxs(reactNative.View,{style:Le.rightContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[Le.amount,{color:o.foreground}],children:p}),jsxRuntime.jsx(Ge,{size:20,color:o.foregroundMuted,strokeWidth:2})]})]})}var Le=reactNative.StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12,borderRadius:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-2,right:-2,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"}});var{height:Un}=reactNative.Dimensions.get("window");function _r(e,t){let o={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||o[e]||e:o[e]||e}function Ir(e,t=6){if(!e)return "\u2014";try{let o=Number(e)/Math.pow(10,t);return o===0?"0.00":o>=1?o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function On(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var vr=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function Dr(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function Nn(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 fo({visible:e,onClose:t,executions:o,externalUserId:n,publishableKey:l}){let{colors:s}=V(),[u,w]=react.useState(o),[p,k]=react.useState(false),[r,T]=react.useState(null),[a,S]=react.useState(false),W=react.useRef(null);react.useEffect(()=>{if(!e||!n)return;let m=async()=>{k(true);try{let re=[...(await Tt(n,l)).data].sort((ne,P)=>{let xe=ne.created_at?new Date(ne.created_at).getTime():0;return (P.created_at?new Date(P.created_at).getTime():0)-xe});w(re);}catch(U){console.error("Failed to fetch executions:",U),w(o);}finally{k(false);}};m();let G=setInterval(m,1e4);return ()=>clearInterval(G)},[e,n,l,o]),react.useEffect(()=>{o.length>0&&w(m=>{let G=new Set(m.map(re=>re.id)),U=o.filter(re=>!G.has(re.id));return U.length>0?[...U,...m]:m});},[o]),react.useEffect(()=>{e||T(null);},[e]);let j=m=>{T(m);},E=()=>{T(null),S(false);},x=()=>{T(null),t();};return jsxRuntime.jsxs(Y,{visible:e,onClose:x,closeOnBackdropPress:true,showHandle:false,heightPercent:.6,children:[jsxRuntime.jsx(de,{title:r?"Deposit Details":"Deposit Tracker",onClose:x,showClose:!r,showBack:!!r,onBack:E}),r?(()=>{if(!r)return null;let m=r,G=m.status==="pending"||m.status==="waiting"||m.status==="delayed",U=m.status==="succeeded",re=H(te(m.destination_token_metadata,"png")||ie("/icons/tokens/png/usdc.png")),ne=m.provider_metadata?.details,P=ne?.currencyIn,xe=ne?.currencyOut;P?.currency?.symbol||"USDC";xe?.currency?.symbol||"USDC";let be=Ir(m.source_amount_base_unit,m.source_token_metadata?.decimals),se=Ir(m.destination_amount_base_unit,m.destination_token_metadata?.decimals),Se=On(m.source_amount_usd),fe=_r(m.source_chain_type,m.source_chain_id),Oe=_r(m.destination_chain_type,m.destination_chain_id),wt=()=>{m.explorer_url&&reactNative.Linking.openURL(m.explorer_url);},Ne=()=>{m.destination_explorer_url&&reactNative.Linking.openURL(m.destination_explorer_url);};return jsxRuntime.jsxs(reactNative.ScrollView,{ref:W,style:y.scrollContainer,contentContainerStyle:y.detailsContent,showsVerticalScrollIndicator:false,children:[jsxRuntime.jsxs(reactNative.View,{style:y.iconSection,children:[jsxRuntime.jsxs(reactNative.View,{style:y.iconWrapper,children:[jsxRuntime.jsx(reactNative.Image,{source:{uri:re},style:y.tokenIcon}),jsxRuntime.jsx(reactNative.View,{style:[y.statusBadge,{backgroundColor:G?"#EAB308":"#22C55E",borderColor:s.background}],children:G?jsxRuntime.jsx(ce,{size:14,color:"#FFFFFF",strokeWidth:2}):jsxRuntime.jsx(oe,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxRuntime.jsxs(reactNative.View,{style:y.statusRow,children:[jsxRuntime.jsx(reactNative.View,{style:[y.statusDot,{backgroundColor:G?"#EAB308":"#22C55E"}]}),jsxRuntime.jsx(reactNative.Text,{style:[y.statusText,{color:s.foreground}],children:G?"Processing":"Completed"})]}),jsxRuntime.jsx(reactNative.Text,{style:[y.dateText,{color:s.foregroundMuted}],children:Nn(m.created_at||new Date().toISOString())})]}),jsxRuntime.jsxs(reactNative.View,{style:[y.card,{backgroundColor:s.card}],children:[jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Amount Sent"}),jsxRuntime.jsxs(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:[be," ",Dr(m.source_currency)]})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Amount Received"}),jsxRuntime.jsxs(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:[se," ",Dr(m.destination_currency)]})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"USD Value"}),jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:Se})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Source Network"}),jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:fe})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Destination Network"}),jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:Oe})]})]}),jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:()=>{let qe=!a;S(qe),qe?setTimeout(()=>{W.current?.scrollToEnd({animated:true});},100):W.current?.scrollTo({y:0,animated:true});},style:y.toggleButton,activeOpacity:.7,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.toggleText,{color:s.foregroundMuted}],children:a?"See less":"See more details"}),a?jsxRuntime.jsx(dt,{size:14,color:s.foregroundMuted,strokeWidth:2}):jsxRuntime.jsx(ce,{size:14,color:s.foregroundMuted,strokeWidth:2})]}),a&&jsxRuntime.jsxs(reactNative.View,{style:[y.card,{backgroundColor:s.card}],children:[m.explorer_url&&jsxRuntime.jsxs(reactNative.View,{children:[jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:wt,style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Deposit Tx"}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRowRight,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:vr(m.transaction_hash)}),jsxRuntime.jsx(Ye,{size:14,color:s.foregroundMuted,strokeWidth:2})]})]}),jsxRuntime.jsx(reactNative.View,{style:[y.cardDivider,{backgroundColor:s.border}]})]}),m.destination_explorer_url&&U&&jsxRuntime.jsxs(reactNative.TouchableOpacity,{onPress:Ne,style:y.cardRow,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Completion Tx"}),jsxRuntime.jsxs(reactNative.View,{style:y.cardRowRight,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.cardValue,{color:s.foreground}],children:vr(m.destination_transaction_hashes[0])}),jsxRuntime.jsx(Ye,{size:14,color:s.foregroundMuted,strokeWidth:2})]})]})]})]})})():jsxRuntime.jsx(reactNative.ScrollView,{style:y.scrollContainer,contentContainerStyle:y.scrollContent,showsVerticalScrollIndicator:false,children:u.length===0?jsxRuntime.jsxs(reactNative.View,{style:y.emptyContainer,children:[jsxRuntime.jsx(reactNative.Text,{style:[y.emptyText,{color:s.foregroundMuted}],children:"No deposits yet"}),jsxRuntime.jsx(reactNative.Text,{style:[y.emptySubtext,{color:s.foregroundMuted}],children:"Your deposit history will appear here"})]}):jsxRuntime.jsx(reactNative.View,{style:y.executionsList,children:u.map(m=>jsxRuntime.jsx(uo,{execution:m,onPress:()=>j(m)},m.id))})})]})}var y=reactNative.StyleSheet.create({scrollContainer:{maxHeight:Un*.7,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:16},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 Bt(e,t=true){let[o,n]=react.useState(null),[l,s]=react.useState(null),[u,w]=react.useState(false),[p,k]=react.useState(false),[r,T]=react.useState(null),[a,S]=react.useState(null);react.useEffect(()=>{!t||o||(w(true),Io().then(x=>{n(x),T(null);}).catch(x=>{T(x instanceof Error?x:new Error(String(x)));}).finally(()=>{w(false);}));},[t,o]),react.useEffect(()=>{!t||!e||l||(k(true),St(e).then(x=>{s(x),S(null);}).catch(x=>{S(x instanceof Error?x:new Error(String(x)));}).finally(()=>{k(false);}));},[t,e,l]);let W=u||p,j=r||a||null,E=null;if(o&&l){let x=l.blocked_country_codes||[],L=o.alpha2.toUpperCase();E=!x.some(F=>F.toUpperCase()===L);}return {isAllowed:E,alpha2:o?.alpha2?.toLowerCase()??null,country:o?.country??null,isLoading:W,error:j}}var ot={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function Yn({visible:e,onClose:t,externalUserId:o,publishableKey:n,modalTitle:l="Deposit",destinationTokenSymbol:s,recipientAddress:u,destinationChainType:w,destinationChainId:p,destinationTokenAddress:k,hideDepositTracker:r=false,onDepositSuccess:T,onDepositError:a}){let{colors:S}=V(),[W,j]=react.useState([]),[E,x]=react.useState(false),[L,F]=react.useState(false),[m,G]=react.useState(false),[U,re]=react.useState(null),[ne,P]=react.useState("amount"),{isAllowed:xe,isLoading:Ue}=Bt(n,e);react.useEffect(()=>{e&&!U&&St(n).then(re).catch(console.error);},[e,U,n]);let ke=()=>{t();},be=W.filter(fe=>fe.status==="pending"||fe.status==="waiting").length,se=Ue||e&&!U,Se=xe===false;return jsxRuntime.jsxs(Y,{visible:e,onClose:ke,closeOnBackdropPress:false,showHandle:false,children:[jsxRuntime.jsx(de,{title:l,showBack:false,onClose:ke}),se&&jsxRuntime.jsx(reactNative.View,{style:Be.centeredContainer,children:jsxRuntime.jsx(reactNative.ActivityIndicator,{size:"large",color:S.primary})}),!se&&Se&&jsxRuntime.jsxs(reactNative.View,{style:Be.centeredContainer,children:[jsxRuntime.jsx(reactNative.View,{style:[Be.iconContainer,{backgroundColor:S.cardHover}],children:jsxRuntime.jsx($t,{size:32,color:S.foreground,strokeWidth:1.5})}),jsxRuntime.jsx(reactNative.Text,{style:[Be.blockedTitle,{color:S.foreground}],children:"No Tokens Available"}),jsxRuntime.jsx(reactNative.Text,{style:[Be.blockedDescription,{color:S.foreground,opacity:.7}],children:"There are no supported tokens available from your current location."})]}),!se&&!Se&&jsxRuntime.jsxs(reactNative.View,{style:Be.optionsContainer,children:[jsxRuntime.jsx(It,{onPress:()=>F(true),title:ot.transferCrypto.title,subtitle:ot.transferCrypto.subtitle,featuredTokens:U?.transfer_crypto?.networks}),jsxRuntime.jsx(Dt,{onPress:()=>G(true),title:ot.depositWithCard.title,subtitle:ot.depositWithCard.subtitle,paymentNetworks:U?.payment_networks?.networks}),!r&&jsxRuntime.jsx(Vt,{onPress:()=>x(true),title:ot.depositTracker.title,subtitle:ot.depositTracker.subtitle,badge:be>0?be:void 0})]}),jsxRuntime.jsx(fo,{visible:E,onClose:()=>x(false),executions:W,externalUserId:o,publishableKey:n}),jsxRuntime.jsxs(Y,{visible:L,onClose:()=>F(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsxRuntime.jsx(de,{title:ot.transferCrypto.title,showBack:false,onClose:()=>F(false)}),jsxRuntime.jsx(reactNative.ScrollView,{style:Be.transferScrollContainer,contentContainerStyle:Be.scrollContent,showsVerticalScrollIndicator:false,children:jsxRuntime.jsx(oo,{externalUserId:o,publishableKey:n,recipientAddress:u,destinationChainType:w,destinationChainId:p,destinationTokenAddress:k,destinationTokenSymbol:s,onExecutionsChange:j,onDepositSuccess:T,onDepositError:a})})]}),jsxRuntime.jsxs(Y,{visible:m,onClose:()=>{G(false),P("amount");},closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsxRuntime.jsx(de,{title:`Deposit ${s||"USDC"}`,showBack:ne==="onramp",onBack:()=>P("amount"),onClose:()=>{G(false),P("amount");}}),jsxRuntime.jsx(reactNative.View,{style:Be.buyWithCardContainer,children:jsxRuntime.jsx(ao,{externalUserId:o,publishableKey:n,destinationTokenSymbol:s,recipientAddress:u,destinationChainType:w,destinationChainId:p,destinationTokenAddress:k,onDepositSuccess:T,onDepositError:a,view:ne,onViewChange:fe=>P(fe)})})]})]})}function go({theme:e="auto",...t}){return jsxRuntime.jsx(xt,{mode:e,children:jsxRuntime.jsx(Yn,{...t})})}var Be=reactNative.StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1},centeredContainer:{alignItems:"center",justifyContent:"center",paddingVertical:48,paddingHorizontal:16,minHeight:200},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}});reactNative.StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});reactNative.StyleSheet.create({icon:{backgroundColor:"transparent"}});var ii=()=>new reactQuery.QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),Lr=react.createContext(null);function si({children:e,publishableKey:t,config:o}){let[n]=react.useState(()=>ii()),[l,s]=react.useState(false),[u,w]=react.useState(null),p=reactNative.useColorScheme(),k=react.useRef(false);k.current||(Ot({publishableKey:t}),k.current=true);let r=react.useMemo(()=>{let L=o?.appearance||"dark";return L==="auto"?p==="dark"?"dark":"light":L},[o?.appearance,p]);react.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.'),Ot({publishableKey:t});},[t]);let T=react.useRef(null),a=react.useRef(null),S=react.useCallback(L=>{console.log("[UnifoldProvider] beginDeposit called with:",L),a.current&&(clearTimeout(a.current),a.current=null),T.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),T.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),T.current=null);let F=new Promise((m,G)=>{T.current={resolve:m,reject:G};});return w(L),s(true),F},[]),W=react.useCallback(()=>{T.current&&(T.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),T.current=null),s(false),a.current=setTimeout(()=>{w(null),a.current=null;},200);},[]),j=react.useCallback(L=>{console.log("[UnifoldProvider] Deposit success:",L),u?.onSuccess&&u.onSuccess(L),T.current&&(T.current.resolve(L),T.current=null);},[u]),E=react.useCallback(L=>{console.error("[UnifoldProvider] Deposit error:",L),u?.onError&&u.onError(L),T.current&&(T.current.reject(L),T.current=null);},[u]),x=react.useMemo(()=>({publishableKey:t,beginDeposit:S,closeDeposit:W}),[t,S,W]);return jsxRuntime.jsx(reactQuery.QueryClientProvider,{client:n,children:jsxRuntime.jsx(Lr.Provider,{value:x,children:jsxRuntime.jsxs(xt,{mode:r,children:[e,u&&jsxRuntime.jsx(go,{visible:l,onClose:W,publishableKey:t,modalTitle:o?.modalTitle,externalUserId:u.externalUserId,destinationChainType:u.destinationChainType,destinationChainId:u.destinationChainId,destinationTokenSymbol:u.destinationTokenSymbol,recipientAddress:u.recipientAddress,destinationTokenAddress:u.destinationTokenAddress,hideDepositTracker:o?.hideDepositTracker,onDepositSuccess:j,onDepositError:E,theme:r})]})})})}function ai(){let e=react.useContext(Lr);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
2
+ exports.UnifoldProvider=si;exports.setDevApiUrl=Jo;exports.useAllowedCountry=Bt;exports.useUnifold=ai;
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {createContext,useState,useRef,useMemo,useEffect,useCallback,useContext}from'react';import {Dimensions,StyleSheet,Platform,useColorScheme,View,ScrollView,Animated,Modal,TouchableWithoutFeedback,TouchableOpacity,Text,Image,ActivityIndicator,TextInput,Linking,Clipboard,Easing}from'react-native';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import Z,{Line,Polyline,Path,SvgUri,Rect,Circle}from'react-native-svg';import Kr from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var Oo={background:"#ffffff",foreground:"#0f0f0f",foregroundMuted:"#737373",card:"#f5f5f5",cardHover:"#e5e5e5",border:"#e5e5e5",overlay:"rgba(0, 0, 0, 0.5)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Pr={background:"#0f0f0f",foreground:"#fafafa",foregroundMuted:"#a3a3a3",card:"#262626",cardHover:"#404040",border:"#333333",overlay:"rgba(0, 0, 0, 0.7)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},jo=createContext({colors:Oo,isDark:false,mode:"auto"});function ht({children:e,mode:t="auto"}){let o=useColorScheme(),n=useMemo(()=>{let c;return t==="auto"?c=o==="dark":c=t==="dark",{colors:c?Pr:Oo,isDark:c,mode:t}},[t,o]);return jsx(jo.Provider,{value:n,children:e})}function P(){let e=useContext(jo);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}var Lr="https://api.unifold.io",Et,Le="pk_test_123",Mt={};function pe(){return typeof __DEV__<"u"&&__DEV__&&Et?Et:Lr}function zt(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.'),Le=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(Et=e.baseUrl),e.defaultConfig&&(Mt=e.defaultConfig);}function No(e){typeof __DEV__<"u"&&__DEV__?(Et=e,console.log(`[Unifold DEV] API URL set to: ${e}`)):console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function Oe(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 ne(e){let t=e.startsWith("/")?e:`/${e}`;return `${pe()}/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+)?/,pe()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${pe()}${e}`:`${pe()}/api/public${e}`:""}async function qo(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||Mt.destinationChainId||"8453",destination_token_address:e?.destination_token_address||Mt.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||Mt.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},n=t||Le;Oe(n);let c=await fetch(`${pe()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!c.ok)throw new Error(`Failed to create deposit address: ${c.statusText}`);return c.json()}async function mt(e,t){return qo(e?{...e,external_user_id:e.external_user_id}:void 0,t)}function yt(e,t){return e.find(o=>o.chain_type===t)}async function wt(e,t){let o=t||Le;Oe(o);let n=await fetch(`${pe()}/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})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}function X(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let o=e.icon_urls.find(n=>n.format===t);return o?o.url:e.icon_url}async function mo(e){let t=e||Le;Oe(t);let o=await fetch(`${pe()}/v1/public/tokens/supported_deposit_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch supported deposit tokens: ${o.statusText}`);return o.json()}async function yo(e,t){let o=t||Le;Oe(o);let n=await fetch(`${pe()}/v1/public/onramps/meld/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to fetch Meld quotes: ${n.statusText}`);return n.json()}async function wo(e,t){let o=t||Le;Oe(o);let n=await fetch(`${pe()}/v1/public/onramps/meld/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to create Meld session: ${n.statusText}`);return n.json()}async function Co(e){let t=e||Le;Oe(t);let o=await fetch(`${pe()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch fiat currencies: ${o.statusText}`);return o.json()}async function xo(e){let t=e||Le;Oe(t);let o=await fetch(`${pe()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch project config: ${o.statusText}`);return o.json()}var{height:nt}=Dimensions.get("window");function $({visible:e,onClose:t,children:o,closeOnBackdropPress:n=true,showHandle:c=true,heightPercent:s,noPadding:p=false}){let{colors:C}=P(),f=useRef(new Animated.Value(nt)).current,r=useRef(new Animated.Value(0)).current;useEffect(()=>{e?(f.setValue(nt),r.setValue(0),Animated.parallel([Animated.spring(f,{toValue:0,useNativeDriver:true,tension:65,friction:11}),Animated.timing(r,{toValue:.5,duration:200,useNativeDriver:true})]).start()):Animated.parallel([Animated.spring(f,{toValue:nt,useNativeDriver:true,tension:65,friction:11}),Animated.timing(r,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,f,r]);let V=()=>{n&&t();};return jsx(Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxs(View,{style:je.container,children:[jsx(TouchableWithoutFeedback,{onPress:V,children:jsx(Animated.View,{style:[je.backdrop,{backgroundColor:"#000000",opacity:r}]})}),jsxs(Animated.View,{style:[je.sheet,{backgroundColor:C.background,borderTopLeftRadius:24,borderTopRightRadius:24,transform:[{translateY:f}],...s&&{height:nt*s,maxHeight:nt*s},...p&&{paddingBottom:0}}],children:[c&&jsx(View,{style:je.handleContainer,children:jsx(View,{style:[je.handle,{backgroundColor:C.border}]})}),jsx(View,{style:[je.content,s&&je.contentFlex],children:o})]})]})})}var je=StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject},sheet:{maxHeight:nt*.9,paddingBottom:Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingTop:12,paddingBottom:4},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function bo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Z,{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:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function ko({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ct({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function To({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Te({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ne({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Z,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function se({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Z,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function te({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Z,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function qe({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function So({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{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:o,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:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ko({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Z,{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:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Jo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function it({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(Z,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ft({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:o,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:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _o({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Xo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(Z,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function ae({title:e,showBack:t=false,showClose:o=true,onBack:n,onClose:c,badge:s}){let{colors:p}=P();return jsxs(View,{style:ge.header,children:[jsx(View,{style:ge.leftContainer,children:t&&n?jsx(TouchableOpacity,{onPress:n,style:[ge.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(To,{size:20,color:p.foreground,strokeWidth:2})}):jsx(View,{style:ge.spacer})}),jsxs(View,{style:ge.titleContainer,children:[jsx(Text,{style:[ge.title,{color:p.foreground}],children:e}),s&&s.count>0&&jsx(View,{style:[ge.titleBadge,{backgroundColor:p.card}],children:jsx(Text,{style:[ge.titleBadgeText,{color:p.foregroundMuted}],children:s.count})})]}),jsx(View,{style:ge.rightContainer,children:o?jsx(TouchableOpacity,{onPress:c,style:[ge.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Te,{size:20,color:p.foreground,strokeWidth:2})}):jsx(View,{style:ge.spacer})})]})}var ge=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,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,fontWeight:"500",textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function le({uri:e,width:t,height:o,borderRadius:n=0,borderWidth:c=0,borderColor:s="transparent",backgroundColor:p="transparent",style:C}){let[f,r]=useState(false),V=e?.toLowerCase().endsWith(".svg");if(!e)return jsx(View,{style:[{width:t,height:o,borderRadius:n,backgroundColor:"#374151"},C]});let T={width:t,height:o,borderRadius:n,borderWidth:c,borderColor:s,backgroundColor:p,overflow:"hidden",alignItems:"center",justifyContent:"center",...C},a=t-c*2,D=o-c*2;return f?jsx(View,{style:[T,{backgroundColor:p||"#374151"}]}):V?jsx(View,{style:T,children:jsx(SvgUri,{uri:e,width:a,height:D,onError:A=>{console.log(`[RemoteIcon] SVG load error for ${e}:`,A),r(true);}})}):jsx(View,{style:T,children:jsx(Image,{source:{uri:e},style:{width:a,height:D},resizeMode:"contain",onError:A=>{console.log(`[RemoteIcon] Image load error for ${e}:`,A.nativeEvent.error),r(true);}})})}function xt({onPress:e,title:t,subtitle:o,featuredTokens:n}){let{colors:c}=P(),s=n?[...n].sort((p,C)=>p.position-C.position):[];return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Se.container,{backgroundColor:c.card}],children:[jsxs(View,{style:Se.leftContent,children:[jsx(View,{style:[Se.iconContainer,{backgroundColor:c.cardHover}],children:jsx(bo,{size:20,color:c.foreground,strokeWidth:2})}),jsxs(View,{style:Se.textContainer,children:[jsx(Text,{style:[Se.title,{color:c.foreground}],children:t}),jsx(Text,{style:[Se.subtitle,{color:c.foregroundMuted}],children:o})]})]}),jsx(View,{style:Se.rightContent,children:jsx(View,{style:Se.networkIcons,children:s.map((p,C)=>{let f=p.icon_urls.find(r=>r.format==="png")?.url||p.icon_urls.find(r=>r.format==="svg")?.url;return jsx(View,{style:[Se.networkIconWrapper,{marginLeft:C===0?0:-6,zIndex:s.length-C}],children:jsx(le,{uri:z(f),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:c.card})},p.name)})})})]})}var Se=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,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 kt({onPress:e,title:t,subtitle:o,paymentNetworks:n}){let{colors:c}=P();return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Me.container,{backgroundColor:c.card}],children:[jsxs(View,{style:Me.leftContent,children:[jsx(View,{style:[Me.iconContainer,{backgroundColor:c.cardHover}],children:jsx(ko,{size:20,color:c.foreground,strokeWidth:2})}),jsxs(View,{style:Me.textContainer,children:[jsx(Text,{style:[Me.title,{color:c.foreground}],children:t}),jsx(Text,{style:[Me.subtitle,{color:c.foregroundMuted}],children:o})]})]}),jsx(View,{style:Me.rightContent,children:jsx(View,{style:Me.paymentIcons,children:n?.map(s=>{let p=s.icon_urls.find(C=>C.format==="png")?.url||s.icon_urls.find(C=>C.format==="svg")?.url;return jsx(le,{uri:z(p),width:32,height:20,borderRadius:4},s.name)})})})]})}var Me=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,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 Tt({onPress:e,title:t,subtitle:o,badge:n}){let{colors:c}=P();return jsx(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Ee.container,{backgroundColor:c.card}],children:jsxs(View,{style:Ee.leftContent,children:[jsxs(View,{style:[Ee.iconContainer,{backgroundColor:c.cardHover}],children:[jsx(Ct,{size:20,color:c.foreground,strokeWidth:2}),n!==void 0&&n>0&&jsx(View,{style:[Ee.badge,{backgroundColor:c.primary}],children:jsx(Text,{style:Ee.badgeText,children:n>99?"99+":n})})]}),jsxs(View,{style:Ee.textContainer,children:[jsx(Text,{style:[Ee.title,{color:c.foreground}],children:t}),jsx(Text,{style:[Ee.subtitle,{color:c.foregroundMuted}],children:o})]})]})})}var Ee=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,borderRadius:9,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 Ot({value:e,size:t=180,logoUri:o,logoSize:n=40,logoBackgroundColor:c}){let{colors:s,isDark:p}=P(),C=p?"#1a1a1a":"#ffffff",f=p?"#ffffff":"#000000",r=c||C;return jsxs(View,{style:[ir.container,{width:t,height:t}],children:[jsx(Kr,{value:e||"placeholder",size:t,backgroundColor:C,color:f,ecl:"H",quietZone:4}),o&&jsx(View,{style:[ir.logoContainer,{width:n+12,height:n+12,backgroundColor:r,borderRadius:(n+12)/2}],children:jsx(le,{uri:o,width:n,height:n,borderRadius:n/2})})]})}var ir=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function ar(e){let t=e.split("/"),o=t[t.length-1];return o&&o.length>10?`${o.slice(0,6)}...${o.slice(-3)}`:o||""}function nn(e){let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],n=e.getDate(),c=e.getFullYear(),s=e.getHours(),p=e.getMinutes(),C=s>=12?"pm":"am";s=s%12,s=s||12;let f=p<10?`0${p}`:p;return `${o} ${n}, ${c} at ${s}:${f}${C}`}function $t({visible:e,status:t,tokenIconUrl:o,explorerUrl:n,completionExplorerUrl:c,date:s,amountUsd:p,onClose:C}){let{colors:f}=P(),r=useRef(new Animated.Value(0)).current,[V,T]=useState(false),a=t==="pending"||t==="waiting"||t==="delayed",D=t==="succeeded";useEffect(()=>{if(a&&e){let L=Animated.loop(Animated.timing(r,{toValue:1,duration:1e3,easing:Easing.linear,useNativeDriver:true}));return L.start(),()=>L.stop()}else r.setValue(0);},[a,e,r]);let A=r.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]}),O=()=>{n&&Linking.openURL(n);},E=()=>{c&&Linking.openURL(c);};return jsx($,{visible:e,onClose:C,closeOnBackdropPress:true,showHandle:false,children:jsxs(View,{style:N.container,children:[jsx(TouchableOpacity,{style:N.closeButton,onPress:C,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Te,{size:20,color:f.foregroundMuted,strokeWidth:2})}),jsxs(View,{style:N.iconContainer,children:[o?jsx(Image,{source:{uri:z(o)},style:N.tokenIcon}):jsx(View,{style:[N.tokenIcon,{backgroundColor:f.cardHover}]}),jsx(View,{style:[N.statusBadge,{backgroundColor:a?"#F97316":"#22C55E"}],children:a?jsx(Animated.View,{style:{transform:[{rotate:A}]},children:jsx(Ft,{size:16,color:"#fff",strokeWidth:2.5})}):jsx(te,{size:16,color:"#fff",strokeWidth:3})})]}),jsx(Text,{style:[N.title,{color:f.foreground}],children:a?"Deposit Processing":"Deposit Complete"}),p!==void 0&&jsxs(Text,{style:[N.amount,{color:f.foreground}],children:["$",p.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),s&&jsx(Text,{style:[N.date,{color:f.foregroundMuted}],children:nn(s)}),jsx(Text,{style:[N.subtitle,{color:f.foregroundMuted}],children:a?"This usually takes less than a minute.":"Your account has been credited successfully!"}),D&&(n||c)&&jsxs(View,{style:N.detailsSection,children:[jsx(View,{style:[N.divider,{backgroundColor:f.border}]}),jsxs(TouchableOpacity,{style:N.detailsToggle,onPress:()=>T(!V),children:[jsx(Text,{style:[N.detailsToggleText,{color:f.foregroundMuted}],children:V?"See less":"See more details"}),V?jsx(it,{size:18,color:f.foregroundMuted,strokeWidth:2}):jsx(se,{size:18,color:f.foregroundMuted,strokeWidth:2})]}),V&&jsxs(View,{style:N.txButtonsContainer,children:[n&&jsxs(TouchableOpacity,{style:[N.txButton,{backgroundColor:f.card,borderColor:f.border}],onPress:O,children:[jsx(Text,{style:[N.txLabel,{color:f.foreground}],children:"Deposit tx"}),jsx(Text,{style:[N.txHash,{color:f.foregroundMuted}],children:ar(n)}),jsx(qe,{size:16,color:f.foregroundMuted,strokeWidth:2})]}),c&&jsxs(TouchableOpacity,{style:[N.txButton,{backgroundColor:f.card,borderColor:f.border}],onPress:E,children:[jsx(Text,{style:[N.txLabel,{color:f.foreground}],children:"Completion tx"}),jsx(Text,{style:[N.txHash,{color:f.foregroundMuted}],children:ar(c)}),jsx(qe,{size:16,color:f.foregroundMuted,strokeWidth:2})]})]})]})]})})}var N=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},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"}});var St=(e,t)=>`${t}:${e}`,ln=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function Yt({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:n,destinationChainId:c,destinationTokenAddress:s,onExecutionsChange:p,onDepositSuccess:C,onDepositError:f}){let{colors:r}=P(),[V,T]=useState("USDC"),[a,D]=useState("solana:mainnet"),[A,O]=useState([]),[E,L]=useState(true),[I,oe]=useState([]),[h,j]=useState(true),[G,ee]=useState(false),[J,W]=useState(false),[de,re]=useState(false),[vt,me]=useState(false),[Ze,pt]=useState([]),[Fe,et]=useState(new Map),[He]=useState(()=>new Date),[tt,xe]=useState(null),[De,Dt]=useState(false),[Ve,Vt]=useState(null),[uo,be]=useState(false),ft=new Map;I.forEach(u=>{u.chains.forEach(x=>{let M=`${x.chain_type}:${x.chain_id}`;ft.has(M)||ft.set(M,x);});});let Pt=Array.from(ft.values()),Rt=ln(a),Lt=Pt.find(u=>u.chain_type===Rt.chainType&&u.chain_id===Rt.chainId)?.chain_type||"ethereum",Pe=yt(A,Lt)?.address||"";useEffect(()=>{async function u(){try{j(!0),xe(null);let x=await mo(t);if(oe(x.data),x.data.length>0){let M=x.data[0];if(T(M.symbol),M.chains.length>0){let F=M.chains[0];D(St(F.chain_id,F.chain_type));}}}catch(x){console.error("Error fetching supported tokens:",x),xe("Failed to load supported tokens"),f?.({message:"Failed to load supported tokens",error:x});}finally{j(false);}}u();},[t,f]),useEffect(()=>{async function u(){try{L(!0),xe(null);let x=await mt({external_user_id:e,recipient_address:o,destination_chain_type:n,destination_chain_id:c,destination_token_address:s},t);O(x.data);}catch(x){console.error("Error fetching wallets:",x),xe("Failed to load wallets"),f?.({message:"Failed to load wallets",error:x});}finally{L(false);}}u();},[e,o,n,c,s,t,f]),useEffect(()=>{if(!e||!He)return;let u=setInterval(async()=>{try{let x=await wt(e,t),M=null;for(let F of x.data){let ue=F.created_at?new Date(F.created_at):null;if(!ue||ue<=He)continue;let Re=Fe.get(F.id);if(!Re){M=F;break}if(["pending","waiting","delayed"].includes(Re)&&F.status==="succeeded"){M=F;break}}if(M){let F=M;pt(ue=>{let Re=ue.findIndex(gt=>gt.id===F.id);if(Re>=0){let gt=[...ue];return gt[Re]=F,gt}else return [...ue,F]}),et(ue=>{let Re=new Map(ue);return Re.set(F.id,F.status),Re}),Vt(F),Dt(!0),F.status==="succeeded"&&C?.({message:"Deposit completed successfully",executionId:F.id}),p?.([...Ze,F]);}}catch(x){console.error("Error polling executions:",x),f?.({message:"Failed to check deposit status",error:x});}},5e3);return ()=>clearInterval(u)},[e,t,He,Fe,Ze,p,C,f]),useEffect(()=>{if(!I.length)return;let u=I.find(M=>M.symbol===V);if(!u||u.chains.length===0)return;if(!u.chains.some(M=>St(M.chain_id,M.chain_type)===a)){let M=u.chains[0];D(St(M.chain_id,M.chain_type));}},[V,I,a]);let Ue=I.find(u=>u.symbol===V),Bt=Ue?.chains||[],ke=Bt.find(u=>St(u.chain_id,u.chain_type)===a),fo=async()=>{if(Pe)try{Clipboard.setString(Pe),ee(!0),setTimeout(()=>ee(!1),2e3);}catch(u){console.error("Failed to copy:",u);}},Wt=ke?.estimated_price_impact_percent??0,ot=ke?.max_slippage_percent??.25,go=ke?.minimum_deposit_amount_usd??3;if(h)return jsxs(View,{style:i.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:r.primary}),jsx(Text,{style:[i.loadingText,{color:r.foregroundMuted}],children:"Loading currencies..."})]});if(tt&&I.length===0)return jsxs(View,{style:i.errorContainer,children:[jsx(Text,{style:[i.errorText,{color:r.error}],children:tt}),jsx(Text,{style:[i.errorHint,{color:r.foregroundMuted}],children:"Please check your network connection and try again."})]});let ho=()=>jsxs($,{visible:de,onClose:()=>re(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsx(View,{style:i.sheetHeaderSpacer}),jsx(Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Select Token"}),jsx(TouchableOpacity,{onPress:()=>re(false),style:i.sheetCloseButton,children:jsx(Te,{size:20,color:r.foreground,strokeWidth:2})})]}),jsx(ScrollView,{style:i.sheetList,showsVerticalScrollIndicator:false,children:I.map(u=>jsxs(TouchableOpacity,{onPress:()=>{T(u.symbol),re(false);},style:[i.sheetItem,{backgroundColor:V===u.symbol?r.card:"transparent"}],children:[jsx(Image,{source:{uri:z(X(u,"png"))},style:i.sheetItemIcon}),jsxs(View,{style:i.sheetItemText,children:[jsx(Text,{style:[i.sheetItemTitle,{color:r.foreground}],children:u.symbol}),jsxs(Text,{style:[i.sheetItemSubtitle,{color:r.foregroundMuted}],children:[u.chains.length," network",u.chains.length!==1?"s":""," available"]})]}),V===u.symbol&&jsx(te,{size:20,color:r.primary,strokeWidth:2})]},u.symbol))})]}),m=()=>jsxs($,{visible:vt,onClose:()=>me(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsx(View,{style:i.sheetHeaderSpacer}),jsx(Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Select Network"}),jsx(TouchableOpacity,{onPress:()=>me(false),style:i.sheetCloseButton,children:jsx(Te,{size:20,color:r.foreground,strokeWidth:2})})]}),jsx(ScrollView,{style:i.sheetList,showsVerticalScrollIndicator:false,children:Bt.map(u=>{let x=St(u.chain_id,u.chain_type),M=a===x;return jsxs(TouchableOpacity,{onPress:()=>{D(x),me(false);},style:[i.sheetItem,{backgroundColor:M?r.card:"transparent"}],children:[jsx(Image,{source:{uri:z(X(u,"png"))},style:i.sheetItemIcon}),jsxs(View,{style:i.sheetItemText,children:[jsx(Text,{style:[i.sheetItemTitle,{color:r.foreground}],children:u.chain_name}),jsxs(Text,{style:[i.sheetItemSubtitle,{color:r.foregroundMuted}],children:["Min deposit: $",u.minimum_deposit_amount_usd]})]}),M&&jsx(te,{size:20,color:r.primary,strokeWidth:2})]},x)})})]});return jsxs(View,{style:i.container,children:[jsxs(View,{style:i.selectorSection,children:[jsx(Text,{style:[i.selectorLabel,{color:r.foregroundMuted}],children:"Token"}),jsxs(TouchableOpacity,{onPress:()=>re(true),style:[i.selector,{backgroundColor:r.card}],children:[Ue&&jsx(Image,{source:{uri:z(X(Ue,"png"))},style:i.selectorIcon}),jsx(Text,{style:[i.selectorText,{color:r.foreground}],children:V}),jsx(se,{size:16,color:r.foregroundMuted,strokeWidth:2})]})]}),jsxs(View,{style:i.selectorSection,children:[jsxs(Text,{style:[i.selectorLabel,{color:r.foregroundMuted}],children:["Network"," ",jsxs(Text,{style:i.minDeposit,children:["($",go," min)"]})]}),jsxs(TouchableOpacity,{onPress:()=>me(true),style:[i.selector,{backgroundColor:r.card}],children:[ke&&jsx(Image,{source:{uri:z(X(ke,"png"))},style:i.selectorIcon}),jsx(Text,{style:[i.selectorText,{color:r.foreground}],numberOfLines:1,children:ke?.chain_name||"Select network"}),jsx(se,{size:16,color:r.foregroundMuted,strokeWidth:2})]})]}),jsx(View,{style:i.qrContainer,children:jsx(View,{style:[i.qrWrapper,{backgroundColor:r.background,borderColor:r.border}],children:E?jsxs(View,{style:i.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:r.primary}),jsx(Text,{style:[i.loadingText,{color:r.foregroundMuted}],children:"Loading..."})]}):Pe?jsx(Ot,{value:Pe,size:160,logoUri:z(X(ke,"png")||ne("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:i.qrLoading,children:jsx(Text,{style:[i.errorText,{color:r.error}],children:"No address available"})})})}),jsxs(View,{style:i.addressSection,children:[jsxs(View,{style:i.addressHeader,children:[jsx(Text,{style:[i.addressLabel,{color:r.foregroundMuted}],children:"Deposit Address"}),G&&jsxs(View,{style:i.copiedIndicator,children:[jsx(te,{size:14,color:r.success,strokeWidth:2}),jsx(Text,{style:[i.copiedText,{color:r.success}],children:"Copied"})]})]}),jsx(TouchableOpacity,{onPress:fo,disabled:!Pe||E,activeOpacity:.7,style:[i.addressBox,{backgroundColor:r.card}],children:jsx(Text,{style:[i.addressText,{color:r.foreground}],numberOfLines:2,children:E?"Loading...":Pe||"No address available"})})]}),jsxs(View,{style:[i.detailsCard,{backgroundColor:r.card}],children:[jsxs(TouchableOpacity,{onPress:()=>W(!J),style:i.detailsHeader,children:[jsxs(View,{style:i.detailsRow,children:[jsx(View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsx(Ct,{size:12,color:r.foreground,strokeWidth:2})}),jsxs(Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Processing time:"," ",jsx(Text,{style:{color:r.foreground},children:"< 1 min"})]})]}),jsx(View,{style:i.chevronContainer,children:J?jsx(it,{size:16,color:r.foregroundMuted,strokeWidth:2}):jsx(se,{size:16,color:r.foregroundMuted,strokeWidth:2})})]}),J&&jsxs(View,{style:i.detailsContent,children:[jsxs(View,{style:i.detailsRow,children:[jsx(View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsx(So,{size:12,color:r.foreground,strokeWidth:2})}),jsxs(Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Price impact:"," ",jsxs(Text,{style:{color:r.foreground},children:[Wt.toFixed(2),"%"]})]}),jsx(TouchableOpacity,{onPress:()=>be(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(_o,{size:14,color:r.foregroundMuted,strokeWidth:2})})]}),jsxs(View,{style:i.detailsRow,children:[jsx(View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsx(Ko,{size:12,color:r.foreground,strokeWidth:2})}),jsxs(Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Max slippage:"," ",jsxs(Text,{style:{color:r.foreground},children:[ot.toFixed(2),"%"]})]}),jsx(TouchableOpacity,{onPress:()=>be(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(_o,{size:14,color:r.foregroundMuted,strokeWidth:2})})]}),jsxs(View,{style:i.detailsRow,children:[jsx(View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsx(Jo,{size:12,color:r.foreground,strokeWidth:2})}),jsxs(Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Need help?"," ",jsx(Text,{style:{color:r.foreground,textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(TouchableOpacity,{style:i.termsContainer,children:jsx(Text,{style:[i.termsText,{color:r.foregroundMuted}],children:"Terms apply"})}),ho(),m(),jsxs($,{visible:uo,onClose:()=>be(false),closeOnBackdropPress:true,showHandle:true,children:[jsxs(View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsx(View,{style:i.sheetHeaderSpacer}),jsx(Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity,{onPress:()=>be(false),style:i.sheetCloseButton,children:jsx(Te,{size:20,color:r.foreground,strokeWidth:2})})]}),jsxs(View,{style:i.infoSheetContent,children:[jsxs(View,{style:[i.infoCard,{backgroundColor:r.card}],children:[jsxs(View,{style:i.infoCardHeader,children:[jsx(View,{style:[i.infoCardIcon,{backgroundColor:r.cardHover}],children:jsx(So,{size:16,color:r.foreground,strokeWidth:2})}),jsx(Text,{style:[i.infoCardTitle,{color:r.foreground}],children:"Price Impact"}),jsxs(Text,{style:[i.infoCardValue,{color:r.foreground}],children:[Wt.toFixed(2),"%"]})]}),jsx(Text,{style:[i.infoCardDescription,{color:r.foregroundMuted}],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:[i.infoCard,{backgroundColor:r.card}],children:[jsxs(View,{style:i.infoCardHeader,children:[jsx(View,{style:[i.infoCardIcon,{backgroundColor:r.cardHover}],children:jsx(Xo,{size:16,color:r.foreground,strokeWidth:2})}),jsx(Text,{style:[i.infoCardTitle,{color:r.foreground}],children:"Max Slippage"}),jsxs(Text,{style:[i.infoCardValue,{color:r.foreground}],children:[ot.toFixed(2),"%"]})]}),jsx(Text,{style:[i.infoCardDescription,{color:r.foregroundMuted}],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."})]})]})]}),Ve&&jsx($t,{visible:De,status:Ve.status,tokenIconUrl:Ve.destination_token_metadata?.icon_urls?.find(u=>u.format==="png")?.url||Ve.destination_token_metadata?.icon_url||X(Ue,"png"),explorerUrl:Ve.explorer_url,completionExplorerUrl:Ve.destination_explorer_url,onClose:()=>Dt(false)})]})}var i=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,borderRadius:16,borderWidth:1},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:{paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,paddingLeft:8,paddingRight:24},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:{maxHeight:400,paddingTop:8},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 Kt({currency:e,isSelected:t,onSelect:o}){let{colors:n}=P();return jsxs(TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[Ye.container,{backgroundColor:n.card}],children:[jsxs(View,{style:Ye.leftContent,children:[jsx(View,{style:[Ye.iconContainer,{backgroundColor:n.background}],children:jsx(Image,{source:{uri:z(X(e,"png"))},style:Ye.icon})}),jsxs(View,{style:Ye.textContainer,children:[jsx(Text,{style:[Ye.name,{color:n.foreground}],children:e.name}),jsx(Text,{style:[Ye.code,{color:n.foregroundMuted}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(te,{size:16,color:n.foreground,strokeWidth:2})]})}var Ye=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,borderRadius: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 It({title:e,currencies:t,selectedCurrency:o,onSelect:n}){let{colors:c}=P();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:pr.headerContainer,children:jsx(Text,{style:[pr.title,{color:c.foregroundMuted}],children:e})}),t.map(s=>jsx(Kt,{currency:s,isSelected:o.toLowerCase()===s.currency_code.toLowerCase(),onSelect:n},s.currency_code))]})}var pr=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function Xt({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:n,selectedCurrency:c,onSelectCurrency:s}){let{colors:p}=P(),[C,f]=useState(""),r=n.map(E=>o.find(L=>L.currency_code.toLowerCase()===E.toLowerCase())).filter(E=>E!==void 0),V=o.filter(E=>!n.includes(E.currency_code.toLowerCase())),T=E=>{if(!C)return E;let L=C.toLowerCase();return E.filter(I=>I.name.toLowerCase().includes(L)||I.currency_code.toLowerCase().includes(L))},a=T(r),D=T(V),A=E=>{s(E),t(false),f("");},O=()=>{t(false),f("");};return jsxs($,{visible:e,onClose:O,closeOnBackdropPress:true,showHandle:false,children:[jsx(ae,{title:"Currency",showBack:false,onClose:O}),jsx(View,{style:Ke.searchContainer,children:jsx(TextInput,{style:[Ke.searchInput,{backgroundColor:p.card,color:p.foreground}],value:C,onChangeText:f,placeholder:"Search",placeholderTextColor:p.foregroundMuted})}),jsx(ScrollView,{style:Ke.listContainer,showsVerticalScrollIndicator:false,children:jsxs(View,{style:Ke.listContent,children:[jsx(It,{title:"Popular currencies",currencies:a,selectedCurrency:c,onSelect:A}),a.length>0&&D.length>0&&jsx(View,{style:Ke.sectionSpacer}),jsx(It,{title:"All currencies",currencies:D,selectedCurrency:c,onSelect:A}),a.length===0&&D.length===0&&jsx(View,{style:Ke.noResultsContainer,children:jsx(Text,{style:[Ke.noResultsText,{color:p.foregroundMuted}],children:"No currencies found"})})]})})]})}var Ke=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:16,paddingBottom:12},searchInput:{padding:16,borderRadius:12,fontSize:14},listContainer:{height:400,paddingHorizontal:12},listContent:{paddingBottom:24,minHeight:400},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});var Tn=[100,500,1e3];function hr(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 eo({externalUserId:e,publishableKey:t,view:o,onViewChange:n,maxAmountUsd:c=5e4,destinationTokenSymbol:s="USDC",recipientAddress:p,destinationChainType:C,destinationChainId:f,destinationTokenAddress:r,onDepositSuccess:V,onDepositError:T}){let{colors:a}=P(),[D,A]=useState("500.00"),[O,E]=useState("usd"),[L,I]=useState([]),[oe,h]=useState(false),[j,G]=useState(null),[ee,J]=useState("amount"),[W,de]=useState(null),[re,vt]=useState([]),[me,Ze]=useState(true),[pt,Fe]=useState(60),[et,He]=useState([]),[tt,xe]=useState([]),[De,Dt]=useState(null),[Ve,Vt]=useState(false),[uo,be]=useState(false),[ft,Pt]=useState(false),[Rt,Uo]=useState(null),Lt=o??ee,po=et.find(m=>m.currency_code.toLowerCase()===O.toLowerCase()),Pe=useCallback(m=>{J(m),m==="quotes"?n?.(m,L.length):n?.(m);},[L.length,n]);useEffect(()=>{async function m(){try{let u=await mt({external_user_id:e,recipient_address:p,destination_chain_type:C,destination_chain_id:f,destination_token_address:r},t);vt(u.data);}catch(u){console.error("Error fetching wallets:",u),G("Failed to load wallet addresses");}finally{Ze(false);}}m();},[e,p,C,f,r,t]),useEffect(()=>{async function m(){try{let u=await Co(t);He(u.data),xe(u.preferred||[]);}catch(u){console.error("Error fetching fiat currencies:",u);}}m();},[t]),useEffect(()=>{let m=parseFloat(D);if(isNaN(m)||m<=0){I([]);return}if(O.toLowerCase()==="usd"&&m>c){I([]),G(`Maximum amount is ${hr("usd")}${c.toLocaleString()}`);return}let u=setTimeout(()=>{Ue(m);},500);return ()=>clearTimeout(u)},[D,O,c,t]);let Ue=async m=>{h(true),G(null);try{let u={country_code:"US",destination_currency_code:"usdc_polygon",source_amount:m.toString(),source_currency_code:O.toLowerCase()},x=await yo(u,t);if(I(x.data),x.data.length>0){let M=x.data.reduce((F,ue)=>ue.destination_amount>F.destination_amount?ue:F);de(M);}Fe(60);}catch(u){console.error("Failed to fetch quotes:",u),G("Failed to fetch quotes. Please try again."),I([]);}finally{h(false);}};useEffect(()=>{if(L.length===0)return;let m=setInterval(()=>{Fe(u=>{if(u<=1){let x=parseFloat(D);return !isNaN(x)&&x>0&&Ue(x),60}return u-1});},1e3);return ()=>clearInterval(m)},[L.length,D]);let Bt=m=>{(/^\d*\.?\d{0,2}$/.test(m)||m==="")&&A(m);},ke=m=>{A(m.toFixed(2));},fo=()=>W?W.destination_amount.toFixed(2):"0.00",Wt=async()=>{if(W)try{let m=yt(re,"ethereum");if(!m?.address){G("Wallet address not available");return}let u={service_provider:W.service_provider,country_code:W.country_code.toUpperCase(),destination_currency_code:W.destination_currency_code,source_currency_code:W.source_currency_code,wallet_address:m.address,source_amount:D},x=await wo(u,t);Dt({provider:W,sourceCurrency:O,sourceAmount:D}),Uo(x.widget_url),Pt(!0);}catch(m){console.error("Failed to create session:",m),G("Failed to start payment flow"),T?.({message:"Failed to start payment flow",error:m});}},ot=hr(O),go=()=>{Pt(false),Pe("onramp"),V?.({message:"Payment flow completed",executionId:De?.sessionId});},ho=()=>jsx(Sn,{visible:ft,onClose:go,url:Rt,providerName:W?.service_provider_display_name||"Complete Payment",colors:a});return Lt==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:d.amountViewContainer,children:[jsxs(ScrollView,{style:d.scrollContainer,contentContainerStyle:d.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:d.currencySelector,children:jsxs(TouchableOpacity,{onPress:()=>Vt(true),style:[d.currencyButton,{backgroundColor:a.card}],children:[po&&jsx(Image,{source:{uri:z(X(po,"png"))},style:d.currencyIcon}),jsx(Text,{style:[d.currencyText,{color:a.foreground}],children:O.toUpperCase()}),jsx(se,{size:16,color:a.foregroundMuted,strokeWidth:2})]})}),jsx(Xt,{open:Ve,onOpenChange:Vt,currencies:et,preferredCurrencyCodes:tt,selectedCurrency:O,onSelectCurrency:m=>{E(m.toLowerCase());}}),jsxs(View,{style:d.amountContainer,children:[jsxs(View,{style:d.amountInputRow,children:[jsx(Text,{style:[d.currencySymbol,{color:a.foreground}],children:ot}),jsx(TextInput,{style:[d.amountInput,{color:a.foreground}],value:D,onChangeText:Bt,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:a.foregroundMuted})]}),oe?jsx(ActivityIndicator,{size:"small",color:a.primary}):jsxs(Text,{style:[d.usdcPreview,{color:a.foregroundMuted}],children:["\u2248 ",fo()," ",s]})]}),jsx(View,{style:d.quickAmounts,children:Tn.map(m=>jsx(TouchableOpacity,{onPress:()=>ke(m),style:[d.quickAmountButton,{backgroundColor:a.card},parseFloat(D)===m&&{borderColor:a.primary,borderWidth:2}],children:jsxs(Text,{style:[d.quickAmountText,{color:a.foreground}],children:[ot,m.toLocaleString()]})},m))}),jsxs(View,{style:d.providerSection,children:[jsxs(View,{style:d.providerHeader,children:[jsx(Text,{style:[d.providerLabel,{color:a.foreground}],children:"Provider"}),L.length>0&&!oe&&jsxs(Text,{style:[d.refreshText,{color:a.foregroundMuted}],children:["Refreshing in ",pt,"s"]})]}),jsx(TouchableOpacity,{onPress:()=>be(true),disabled:oe||L.length===0,style:[d.providerButton,{backgroundColor:a.card},(oe||L.length===0)&&d.disabled],children:oe?jsxs(View,{style:d.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:a.foregroundMuted}),jsx(Text,{style:[d.loadingText,{color:a.foregroundMuted}],children:"Finding best rates..."})]}):W?jsxs(View,{style:d.providerContent,children:[jsxs(View,{style:d.providerInfo,children:[jsx(Text,{style:[d.autoPickedText,{color:a.foregroundMuted}],children:"Auto-picked for you"}),jsxs(View,{style:d.providerRow,children:[jsx(le,{uri:z(W.icon_url),width:32,height:32,borderRadius:8}),jsxs(View,{children:[jsx(Text,{style:[d.providerName,{color:a.foreground}],children:W.service_provider_display_name}),jsxs(Text,{style:[d.bestPriceText,{color:a.success}],children:["Best price \u2022 ",W.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(Ne,{size:20,color:a.foregroundMuted,strokeWidth:2})]}):jsx(Text,{style:[d.noProviderText,{color:a.foregroundMuted}],children:parseFloat(D)>0?"No providers available":"Enter an amount to see providers"})}),j&&jsx(Text,{style:[d.errorText,{color:a.error}],children:j})]}),jsxs($,{visible:uo,onClose:()=>be(false),closeOnBackdropPress:true,showHandle:false,children:[jsx(ae,{title:"Select Provider",showBack:false,onClose:()=>be(false),badge:L.length>0?{count:L.length}:void 0}),jsx(ScrollView,{style:d.providerModalList,showsVerticalScrollIndicator:false,children:jsx(View,{style:d.quotesList,children:[...L].sort((m,u)=>u.destination_amount-m.destination_amount).map((m,u)=>{let x=W?.service_provider===m.service_provider,M=u===0;return jsxs(TouchableOpacity,{onPress:()=>{de(m),be(false);},style:[d.quoteItem,{backgroundColor:a.card},x&&{borderColor:a.primary,borderWidth:2}],children:[jsxs(View,{style:d.quoteLeft,children:[jsx(le,{uri:z(m.icon_url),width:32,height:32,borderRadius:8}),jsxs(View,{children:[jsx(Text,{style:[d.quoteName,{color:a.foreground}],children:m.service_provider_display_name}),M&&jsx(Text,{style:[d.bestPriceLabel,{color:a.success}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:d.quoteRight,children:[jsxs(Text,{style:[d.quoteAmount,{color:a.foreground}],children:[m.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[d.quoteSource,{color:a.foregroundMuted}],children:["Fee: ",ot,m.total_fee.toFixed(2)]})]})]},m.service_provider)})})})]})]}),jsx(View,{style:[d.continueButtonContainer,{backgroundColor:a.background}],children:jsx(TouchableOpacity,{onPress:Wt,disabled:oe||me||!W||parseFloat(D)<=0,style:[d.continueButton,{backgroundColor:a.primary},(oe||me||!W)&&d.disabledButton],children:jsx(Text,{style:d.continueButtonText,children:me?"Loading...":"Continue"})})})]}),ho()]}):Lt==="onramp"&&De?jsxs(View,{style:d.onrampContainer,children:[jsx(le,{uri:z(De.provider.icon_url),width:64,height:64,borderRadius:16}),jsxs(Text,{style:[d.onrampTitle,{color:a.foreground}],children:["Complete transaction with ",De.provider.service_provider_display_name]}),jsx(Text,{style:[d.onrampSubtitle,{color:a.foregroundMuted}],children:"You can close this modal."}),jsxs(View,{style:[d.flowDiagram,{backgroundColor:a.card}],children:[jsxs(View,{style:d.flowStep,children:[jsx(Image,{source:{uri:ne(`/icons/currencies/png/${De.sourceCurrency.toLowerCase()}.png`)},style:d.flowIconImage}),jsx(Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You use"}),jsx(Text,{style:[d.flowValue,{color:a.foreground}],children:De.sourceCurrency.toUpperCase()})]}),jsx(Ne,{size:16,color:a.foregroundMuted,strokeWidth:2}),jsxs(View,{style:d.flowStep,children:[jsxs(View,{style:d.flowIconWithBadge,children:[jsx(Image,{source:{uri:ne("/icons/tokens/png/usdc.png")},style:d.flowIconImageNoBadge}),jsx(Image,{source:{uri:ne("/icons/networks/png/polygon.png")},style:[d.flowNetworkBadge,{borderColor:a.background}]})]}),jsx(Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You buy"}),jsx(Text,{style:[d.flowValue,{color:a.foreground}],children:"USDC"})]}),jsx(Ne,{size:16,color:a.foregroundMuted,strokeWidth:2}),jsxs(View,{style:d.flowStep,children:[jsxs(View,{style:d.flowIconWithBadge,children:[jsx(Image,{source:{uri:ne("/icons/tokens/png/usdc.png")},style:d.flowIconImageNoBadge}),jsx(Image,{source:{uri:ne("/icons/networks/png/polygon.png")},style:[d.flowNetworkBadge,{borderColor:a.background}]})]}),jsx(Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You receive"}),jsx(Text,{style:[d.flowValue,{color:a.foreground}],children:s})]})]}),jsx(View,{style:[d.onrampInfoBox,{backgroundColor:a.card}],children:jsx(Text,{style:[d.onrampInfoText,{color:a.foregroundMuted}],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 Sn({visible:e,onClose:t,url:o,providerName:n,colors:c}){return jsxs($,{visible:e,onClose:t,closeOnBackdropPress:false,showHandle:false,heightPercent:.92,noPadding:true,children:[jsxs(View,{style:Je.header,children:[jsx(TouchableOpacity,{onPress:t,style:Je.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(te,{size:20,color:c.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[Je.headerTitle,{color:c.foreground}],children:n}),jsx(View,{style:Je.headerSpacer})]}),o&&jsx(View,{style:Je.container,children:jsx(WebView,{source:{uri:o},style:Je.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:Je.loading,children:jsx(ActivityIndicator,{size:"large",color:c.primary})})})})]})}var Je=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"}}),d=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,borderRadius: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,borderRadius:8},quickAmountText:{fontSize:14,fontWeight:"500"},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16,borderRadius:12},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},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:24},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{color:"#FFFFFF",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:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12,borderRadius: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},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,borderRadius:7,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,borderRadius:12,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 Vn(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 Pn(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function ro({execution:e,onPress:t}){let {colors:o}=P(),n=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let s=z(X(e.destination_token_metadata,"png")||ne("/icons/tokens/png/usdc.png")),p=n?"Deposit Processing":"Deposit Completed",C=Vn(e.created_at||new Date().toISOString()),f=Pn(e.source_amount_usd);return jsxs(TouchableOpacity,{onPress:t,activeOpacity:.7,style:[ve.container,{backgroundColor:o.card}],children:[jsxs(View,{style:ve.iconContainer,children:[jsx(Image,{source:{uri:s},style:ve.tokenIcon}),jsx(View,{style:[ve.statusBadge,{backgroundColor:n?"#EAB308":"#22C55E",borderColor:o.card}],children:n?jsx(Ft,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(te,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:ve.textContainer,children:[jsx(Text,{style:[ve.title,{color:o.foreground}],children:p}),jsx(Text,{style:[ve.dateTime,{color:o.foregroundMuted}],children:C})]}),jsxs(View,{style:ve.rightContainer,children:[jsx(Text,{style:[ve.amount,{color:o.foreground}],children:f}),jsx(Ne,{size:20,color:o.foregroundMuted,strokeWidth:2})]})]})}var ve=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12,borderRadius:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-2,right:-2,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"}});var{height:Mn}=Dimensions.get("window");function Cr(e,t){let o={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||o[e]||e:o[e]||e}function xr(e,t=6){if(!e)return "\u2014";try{let o=Number(e)/Math.pow(10,t);return o===0?"0.00":o>=1?o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function En(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var br=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function kr(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function zn(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 io({visible:e,onClose:t,executions:o,externalUserId:n,publishableKey:c}){let{colors:s}=P(),[p,C]=useState(o),[f,r]=useState(false),[V,T]=useState(null),[a,D]=useState(false),A=useRef(null);useEffect(()=>{if(!e||!n)return;let h=async()=>{r(true);try{let ee=[...(await wt(n,c)).data].sort((J,W)=>{let de=J.created_at?new Date(J.created_at).getTime():0;return (W.created_at?new Date(W.created_at).getTime():0)-de});C(ee);}catch(G){console.error("Failed to fetch executions:",G),C(o);}finally{r(false);}};h();let j=setInterval(h,1e4);return ()=>clearInterval(j)},[e,n,c,o]),useEffect(()=>{o.length>0&&C(h=>{let j=new Set(h.map(ee=>ee.id)),G=o.filter(ee=>!j.has(ee.id));return G.length>0?[...G,...h]:h});},[o]),useEffect(()=>{e||T(null);},[e]);let O=h=>{T(h);},E=()=>{T(null),D(false);},L=()=>{T(null),t();};return jsxs($,{visible:e,onClose:L,closeOnBackdropPress:true,showHandle:false,heightPercent:.6,children:[jsx(ae,{title:V?"Deposit Details":"Deposit Tracker",onClose:L,showClose:!V,showBack:!!V,onBack:E}),V?(()=>{if(!V)return null;let h=V,j=h.status==="pending"||h.status==="waiting"||h.status==="delayed",G=h.status==="succeeded",ee=z(X(h.destination_token_metadata,"png")||ne("/icons/tokens/png/usdc.png")),J=h.provider_metadata?.details,W=J?.currencyIn,de=J?.currencyOut;W?.currency?.symbol||"USDC";de?.currency?.symbol||"USDC";let me=xr(h.source_amount_base_unit,h.source_token_metadata?.decimals),Ze=xr(h.destination_amount_base_unit,h.destination_token_metadata?.decimals),pt=En(h.source_amount_usd),Fe=Cr(h.source_chain_type,h.source_chain_id),et=Cr(h.destination_chain_type,h.destination_chain_id),He=()=>{h.explorer_url&&Linking.openURL(h.explorer_url);},tt=()=>{h.destination_explorer_url&&Linking.openURL(h.destination_explorer_url);};return jsxs(ScrollView,{ref:A,style:y.scrollContainer,contentContainerStyle:y.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:y.iconSection,children:[jsxs(View,{style:y.iconWrapper,children:[jsx(Image,{source:{uri:ee},style:y.tokenIcon}),jsx(View,{style:[y.statusBadge,{backgroundColor:j?"#EAB308":"#22C55E",borderColor:s.background}],children:j?jsx(se,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(te,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:y.statusRow,children:[jsx(View,{style:[y.statusDot,{backgroundColor:j?"#EAB308":"#22C55E"}]}),jsx(Text,{style:[y.statusText,{color:s.foreground}],children:j?"Processing":"Completed"})]}),jsx(Text,{style:[y.dateText,{color:s.foregroundMuted}],children:zn(h.created_at||new Date().toISOString())})]}),jsxs(View,{style:[y.card,{backgroundColor:s.card}],children:[jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Amount Sent"}),jsxs(Text,{style:[y.cardValue,{color:s.foreground}],children:[me," ",kr(h.source_currency)]})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Amount Received"}),jsxs(Text,{style:[y.cardValue,{color:s.foreground}],children:[Ze," ",kr(h.destination_currency)]})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"USD Value"}),jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:pt})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Source Network"}),jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:Fe})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Destination Network"}),jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:et})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let xe=!a;D(xe),xe?setTimeout(()=>{A.current?.scrollToEnd({animated:true});},100):A.current?.scrollTo({y:0,animated:true});},style:y.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[y.toggleText,{color:s.foregroundMuted}],children:a?"See less":"See more details"}),a?jsx(it,{size:14,color:s.foregroundMuted,strokeWidth:2}):jsx(se,{size:14,color:s.foregroundMuted,strokeWidth:2})]}),a&&jsxs(View,{style:[y.card,{backgroundColor:s.card}],children:[h.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:He,style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Deposit Tx"}),jsxs(View,{style:y.cardRowRight,children:[jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:br(h.transaction_hash)}),jsx(qe,{size:14,color:s.foregroundMuted,strokeWidth:2})]})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]})]}),h.destination_explorer_url&&G&&jsxs(TouchableOpacity,{onPress:tt,style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Completion Tx"}),jsxs(View,{style:y.cardRowRight,children:[jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:br(h.destination_transaction_hashes[0])}),jsx(qe,{size:14,color:s.foregroundMuted,strokeWidth:2})]})]})]})]})})():jsx(ScrollView,{style:y.scrollContainer,contentContainerStyle:y.scrollContent,showsVerticalScrollIndicator:false,children:p.length===0?jsxs(View,{style:y.emptyContainer,children:[jsx(Text,{style:[y.emptyText,{color:s.foregroundMuted}],children:"No deposits yet"}),jsx(Text,{style:[y.emptySubtext,{color:s.foregroundMuted}],children:"Your deposit history will appear here"})]}):jsx(View,{style:y.executionsList,children:p.map(h=>jsx(ro,{execution:h,onPress:()=>O(h)},h.id))})})]})}var y=StyleSheet.create({scrollContainer:{maxHeight:Mn*.7,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:16},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}});var Xe={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function Un({visible:e,onClose:t,externalUserId:o,publishableKey:n,modalTitle:c="Deposit",destinationTokenSymbol:s,recipientAddress:p,destinationChainType:C,destinationChainId:f,destinationTokenAddress:r,hideDepositTracker:V=false,onDepositSuccess:T,onDepositError:a}){let[D,A]=useState([]),[O,E]=useState(false),[L,I]=useState(false),[oe,h]=useState(false),[j,G]=useState(null),[ee,J]=useState("amount");useEffect(()=>{e&&!j&&xo(n).then(G).catch(console.error);},[e,j,n]);let W=()=>{t();},de=D.filter(re=>re.status==="pending"||re.status==="waiting").length;return jsxs($,{visible:e,onClose:W,closeOnBackdropPress:false,showHandle:false,children:[jsx(ae,{title:c,showBack:false,onClose:W}),jsxs(View,{style:so.optionsContainer,children:[jsx(xt,{onPress:()=>I(true),title:Xe.transferCrypto.title,subtitle:Xe.transferCrypto.subtitle,featuredTokens:j?.transfer_crypto?.networks}),jsx(kt,{onPress:()=>h(true),title:Xe.depositWithCard.title,subtitle:Xe.depositWithCard.subtitle,paymentNetworks:j?.payment_networks?.networks}),!V&&jsx(Tt,{onPress:()=>E(true),title:Xe.depositTracker.title,subtitle:Xe.depositTracker.subtitle,badge:de>0?de:void 0})]}),jsx(io,{visible:O,onClose:()=>E(false),executions:D,externalUserId:o,publishableKey:n}),jsxs($,{visible:L,onClose:()=>I(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsx(ae,{title:Xe.transferCrypto.title,showBack:false,onClose:()=>I(false)}),jsx(ScrollView,{style:so.transferScrollContainer,contentContainerStyle:so.scrollContent,showsVerticalScrollIndicator:false,children:jsx(Yt,{externalUserId:o,publishableKey:n,recipientAddress:p,destinationChainType:C,destinationChainId:f,destinationTokenAddress:r,onExecutionsChange:A,onDepositSuccess:T,onDepositError:a})})]}),jsxs($,{visible:oe,onClose:()=>{h(false),J("amount");},closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsx(ae,{title:`Deposit ${s||"USDC"}`,showBack:ee==="onramp",onBack:()=>J("amount"),onClose:()=>{h(false),J("amount");}}),jsx(View,{style:so.buyWithCardContainer,children:jsx(eo,{externalUserId:o,publishableKey:n,destinationTokenSymbol:s,recipientAddress:p,destinationChainType:C,destinationChainId:f,destinationTokenAddress:r,onDepositSuccess:T,onDepositError:a,view:ee,onViewChange:re=>J(re)})})]})]})}function lo({theme:e="auto",...t}){return jsx(ht,{mode:e,children:jsx(Un,{...t})})}var so=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var Jn=()=>new QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),_r=createContext(null);function Xn({children:e,publishableKey:t,config:o}){let[n]=useState(()=>Jn()),[c,s]=useState(false),[p,C]=useState(null),f=useColorScheme(),r=useRef(false);r.current||(zt({publishableKey:t}),r.current=true);let V=useMemo(()=>{let I=o?.appearance||"dark";return I==="auto"?f==="dark"?"dark":"light":I},[o?.appearance,f]);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.'),zt({publishableKey:t});},[t]);let T=useRef(null),a=useRef(null),D=useCallback(I=>{console.log("[UnifoldProvider] beginDeposit called with:",I),a.current&&(clearTimeout(a.current),a.current=null),T.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),T.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),T.current=null);let oe=new Promise((h,j)=>{T.current={resolve:h,reject:j};});return C(I),s(true),oe},[]),A=useCallback(()=>{T.current&&(T.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),T.current=null),s(false),a.current=setTimeout(()=>{C(null),a.current=null;},200);},[]),O=useCallback(I=>{console.log("[UnifoldProvider] Deposit success:",I),p?.onSuccess&&p.onSuccess(I),T.current&&(T.current.resolve(I),T.current=null);},[p]),E=useCallback(I=>{console.error("[UnifoldProvider] Deposit error:",I),p?.onError&&p.onError(I),T.current&&(T.current.reject(I),T.current=null);},[p]),L=useMemo(()=>({publishableKey:t,beginDeposit:D,closeDeposit:A}),[t,D,A]);return jsx(QueryClientProvider,{client:n,children:jsx(_r.Provider,{value:L,children:jsxs(ht,{mode:V,children:[e,p&&jsx(lo,{visible:c,onClose:A,externalUserId:p.externalUserId,publishableKey:t,modalTitle:o?.modalTitle,destinationTokenSymbol:p.destinationTokenSymbol,recipientAddress:p.recipientAddress,destinationChainId:p.destinationChainId,destinationTokenAddress:p.destinationTokenAddress,hideDepositTracker:o?.hideDepositTracker,onDepositSuccess:O,onDepositError:E,theme:V})]})})})}function Zn(){let e=useContext(_r);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
2
- export{Xn as UnifoldProvider,No as setDevApiUrl,Zn as useUnifold};
1
+ import {createContext,useState,useEffect,useRef,useMemo,useCallback,useContext}from'react';import {Dimensions,StyleSheet,Platform,useColorScheme,View,ActivityIndicator,Text,ScrollView,Animated,Modal,TouchableWithoutFeedback,TouchableOpacity,Image,TextInput,Linking,Clipboard,Easing}from'react-native';import {QueryClient,QueryClientProvider}from'@tanstack/react-query';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import X,{Path,Line,Polyline,SvgUri,Rect,Circle}from'react-native-svg';import rn from'react-native-qrcode-svg';import {WebView}from'react-native-webview';var Go={background:"#ffffff",foreground:"#0f0f0f",foregroundMuted:"#737373",card:"#f5f5f5",cardHover:"#e5e5e5",border:"#e5e5e5",overlay:"rgba(0, 0, 0, 0.5)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Er={background:"#0f0f0f",foreground:"#fafafa",foregroundMuted:"#a3a3a3",card:"#262626",cardHover:"#404040",border:"#333333",overlay:"rgba(0, 0, 0, 0.7)",primary:"#3b82f6",primaryForeground:"#ffffff",success:"#22c55e",error:"#ef4444",warning:"#f59e0b"},Yo=createContext({colors:Go,isDark:false,mode:"auto"});function xt({children:e,mode:t="auto"}){let o=useColorScheme(),n=useMemo(()=>{let l;return t==="auto"?l=o==="dark":l=t==="dark",{colors:l?Er:Go,isDark:l,mode:t}},[t,o]);return jsx(Yo.Provider,{value:n,children:e})}function V(){let e=useContext(Yo);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}var Fr="https://api.unifold.io",Ut,Ae="pk_test_123",jt={};function ae(){return typeof __DEV__<"u"&&__DEV__&&Ut?Ut:Fr}function Ot(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.'),Ae=e.publishableKey;}e.baseUrl&&typeof __DEV__<"u"&&__DEV__&&(Ut=e.baseUrl),e.defaultConfig&&(jt=e.defaultConfig);}function Jo(e){typeof __DEV__<"u"&&__DEV__?(Ut=e,console.log(`[Unifold DEV] API URL set to: ${e}`)):console.warn("[Unifold] setDevApiUrl() is only available in development mode");}function $e(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 ie(e){let t=e.startsWith("/")?e:`/${e}`;return `${ae()}/api/public${t}`}function H(e){return e?e.includes("localhost")||e.includes("127.0.0.1")?e.replace(/https?:\/\/(localhost|127\.0\.0\.1)(:\d+)?/,ae()):e.startsWith("http://")||e.startsWith("https://")?e:e.startsWith("/api/public/")?`${ae()}${e}`:`${ae()}/api/public${e}`:""}async function Ko(e,t){if(!e?.external_user_id)throw new Error("external_user_id is required");let o={external_user_id:e.external_user_id,destination_chain_type:e?.destination_chain_type||"ethereum",destination_chain_id:e?.destination_chain_id||jt.destinationChainId||"8453",destination_token_address:e?.destination_token_address||jt.destinationTokenAddress||"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",recipient_address:e?.recipient_address||jt.recipientAddress||"0x309a4154a2CD4153Da886E780890C9cb5161553C",client_metadata:e?.client_metadata||{}},n=t||Ae;$e(n);let l=await fetch(`${ae()}/v1/public/deposit_addresses`,{method:"POST",headers:{accept:"application/json","x-publishable-key":n,"Content-Type":"application/json"},body:JSON.stringify(o)});if(!l.ok)throw new Error(`Failed to create deposit address: ${l.statusText}`);return l.json()}async function kt(e,t){return Ko(e?{...e,external_user_id:e.external_user_id}:void 0,t)}function bt(e,t){return e.find(o=>o.chain_type===t)}async function Tt(e,t){let o=t||Ae;$e(o);let n=await fetch(`${ae()}/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})});if(!n.ok)throw new Error(`Failed to query executions: ${n.statusText}`);return n.json()}function te(e,t="svg"){if(!e)return "";if(t==="svg"||!e.icon_urls||e.icon_urls.length===0)return e.icon_url;let o=e.icon_urls.find(n=>n.format===t);return o?o.url:e.icon_url}async function bo(e){let t=e||Ae;$e(t);let o=await fetch(`${ae()}/v1/public/tokens/supported_deposit_tokens`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch supported deposit tokens: ${o.statusText}`);return o.json()}async function To(e,t){let o=t||Ae;$e(o);let n=await fetch(`${ae()}/v1/public/onramps/meld/quotes`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to fetch Meld quotes: ${n.statusText}`);return n.json()}async function So(e,t){let o=t||Ae;$e(o);let n=await fetch(`${ae()}/v1/public/onramps/meld/sessions`,{method:"POST",headers:{accept:"application/json","x-publishable-key":o,"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to create Meld session: ${n.statusText}`);return n.json()}async function _o(e){let t=e||Ae;$e(t);let o=await fetch(`${ae()}/v1/public/onramps/fiat_currencies`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch fiat currencies: ${o.statusText}`);return o.json()}async function St(e){let t=e||Ae;$e(t);let o=await fetch(`${ae()}/v1/public/projects/config`,{method:"GET",headers:{accept:"application/json","x-publishable-key":t}});if(!o.ok)throw new Error(`Failed to fetch project config: ${o.statusText}`);return o.json()}async function Io(){let e=await fetch(`${ae()}/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()}var{height:ct}=Dimensions.get("window");function Y({visible:e,onClose:t,children:o,closeOnBackdropPress:n=true,showHandle:l=true,heightPercent:s,noPadding:u=false}){let{colors:w}=V(),p=useRef(new Animated.Value(ct)).current,k=useRef(new Animated.Value(0)).current;useEffect(()=>{e?(p.setValue(ct),k.setValue(0),Animated.parallel([Animated.spring(p,{toValue:0,useNativeDriver:true,tension:65,friction:11}),Animated.timing(k,{toValue:.5,duration:200,useNativeDriver:true})]).start()):Animated.parallel([Animated.spring(p,{toValue:ct,useNativeDriver:true,tension:65,friction:11}),Animated.timing(k,{toValue:0,duration:200,useNativeDriver:true})]).start();},[e,p,k]);let r=()=>{n&&t();};return jsx(Modal,{visible:e,transparent:true,animationType:"none",statusBarTranslucent:true,onRequestClose:t,children:jsxs(View,{style:Qe.container,children:[jsx(TouchableWithoutFeedback,{onPress:r,children:jsx(Animated.View,{style:[Qe.backdrop,{backgroundColor:"#000000",opacity:k}]})}),jsxs(Animated.View,{style:[Qe.sheet,{backgroundColor:w.background,borderTopLeftRadius:24,borderTopRightRadius:24,transform:[{translateY:p}],...s&&{height:ct*s,maxHeight:ct*s},...u&&{paddingBottom:0}}],children:[l&&jsx(View,{style:Qe.handleContainer,children:jsx(View,{style:[Qe.handle,{backgroundColor:w.border}]})}),jsx(View,{style:[Qe.content,s&&Qe.contentFlex],children:o})]})]})})}var Qe=StyleSheet.create({container:{flex:1,justifyContent:"flex-end"},backdrop:{...StyleSheet.absoluteFillObject},sheet:{maxHeight:ct*.9,paddingBottom:Platform.OS==="ios"?34:24,shadowColor:"#000",shadowOffset:{width:0,height:-4},shadowOpacity:.1,shadowRadius:12,elevation:16},handleContainer:{alignItems:"center",paddingTop:12,paddingBottom:4},handle:{width:36,height:4,borderRadius:2},content:{},contentFlex:{flex:1}});function vo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(X,{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:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Do({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"1",y1:"10",x2:"23",y2:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function _t({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 6 12 12 16 14",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Vo({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"12 19 5 12 12 5",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function De({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"6",y1:"6",x2:"18",y2:"18",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ge({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(X,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"9 18 15 12 9 6",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function ce({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(X,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"6 9 12 15 18 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function oe({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(X,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"20 6 9 17 4 12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function Ye({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"15 3 21 3 21 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"10",y1:"14",x2:"21",y2:"3",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Po({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{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:o,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:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function or({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(X,{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:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function rr({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"14 2 14 8 20 8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"13",x2:"8",y2:"13",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"16",y1:"17",x2:"8",y2:"17",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"10 9 9 9 8 9",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function dt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsx(X,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:jsx(Polyline,{points:"18 15 12 9 6 15",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})})}function qt({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Polyline,{points:"23 4 23 10 17 10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Polyline,{points:"1 20 1 14 7 14",stroke:t,strokeWidth:o,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:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Ro({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[jsx(Circle,{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"16",x2:"12",y2:"12",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"12",y1:"8",x2:"12.01",y2:"8",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function nr({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M9 12l2 2 4-4",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function $t({size:e=24,color:t="#fff",strokeWidth:o=2}){return jsxs(X,{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:o,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:o,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:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Path,{d:"M14.9 9.25a3 3 0 0 0-2.15-2.16",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"}),jsx(Line,{x1:"2",y1:"2",x2:"22",y2:"22",stroke:t,strokeWidth:o,strokeLinecap:"round",strokeLinejoin:"round"})]})}function de({title:e,showBack:t=false,showClose:o=true,onBack:n,onClose:l,badge:s}){let{colors:u}=V();return jsxs(View,{style:we.header,children:[jsx(View,{style:we.leftContainer,children:t&&n?jsx(TouchableOpacity,{onPress:n,style:[we.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(Vo,{size:20,color:u.foreground,strokeWidth:2})}):jsx(View,{style:we.spacer})}),jsxs(View,{style:we.titleContainer,children:[jsx(Text,{style:[we.title,{color:u.foreground}],children:e}),s&&s.count>0&&jsx(View,{style:[we.titleBadge,{backgroundColor:u.card}],children:jsx(Text,{style:[we.titleBadgeText,{color:u.foregroundMuted}],children:s.count})})]}),jsx(View,{style:we.rightContainer,children:o?jsx(TouchableOpacity,{onPress:l,style:[we.iconButton,{backgroundColor:"transparent"}],hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(De,{size:20,color:u.foreground,strokeWidth:2})}):jsx(View,{style:we.spacer})})]})}var we=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,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:8},title:{fontSize:16,fontWeight:"500",textAlign:"center"},titleBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:12},titleBadgeText:{fontSize:10,fontWeight:"400"},iconButton:{width:28,height:28,borderRadius:8,alignItems:"center",justifyContent:"center"},spacer:{width:28,height:28}});function ue({uri:e,width:t,height:o,borderRadius:n=0,borderWidth:l=0,borderColor:s="transparent",backgroundColor:u="transparent",style:w}){let[p,k]=useState(false),r=e?.toLowerCase().endsWith(".svg");if(!e)return jsx(View,{style:[{width:t,height:o,borderRadius:n,backgroundColor:"#374151"},w]});let T={width:t,height:o,borderRadius:n,borderWidth:l,borderColor:s,backgroundColor:u,overflow:"hidden",alignItems:"center",justifyContent:"center",...w},a=t-l*2,S=o-l*2;return p?jsx(View,{style:[T,{backgroundColor:u||"#374151"}]}):r?jsx(View,{style:T,children:jsx(SvgUri,{uri:e,width:a,height:S,onError:W=>{console.log(`[RemoteIcon] SVG load error for ${e}:`,W),k(true);}})}):jsx(View,{style:T,children:jsx(Image,{source:{uri:e},style:{width:a,height:S},resizeMode:"contain",onError:W=>{console.log(`[RemoteIcon] Image load error for ${e}:`,W.nativeEvent.error),k(true);}})})}function It({onPress:e,title:t,subtitle:o,featuredTokens:n}){let{colors:l}=V(),s=n?[...n].sort((u,w)=>u.position-w.position):[];return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Ve.container,{backgroundColor:l.card}],children:[jsxs(View,{style:Ve.leftContent,children:[jsx(View,{style:[Ve.iconContainer,{backgroundColor:l.cardHover}],children:jsx(vo,{size:20,color:l.foreground,strokeWidth:2})}),jsxs(View,{style:Ve.textContainer,children:[jsx(Text,{style:[Ve.title,{color:l.foreground}],children:t}),jsx(Text,{style:[Ve.subtitle,{color:l.foregroundMuted}],children:o})]})]}),jsx(View,{style:Ve.rightContent,children:jsx(View,{style:Ve.networkIcons,children:s.map((u,w)=>{let p=u.icon_urls.find(k=>k.format==="png")?.url||u.icon_urls.find(k=>k.format==="svg")?.url;return jsx(View,{style:[Ve.networkIconWrapper,{marginLeft:w===0?0:-6,zIndex:s.length-w}],children:jsx(ue,{uri:H(p),width:20,height:20,borderRadius:10,borderWidth:2,borderColor:l.card})},u.name)})})})]})}var Ve=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,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 Dt({onPress:e,title:t,subtitle:o,paymentNetworks:n}){let{colors:l}=V();return jsxs(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[ze.container,{backgroundColor:l.card}],children:[jsxs(View,{style:ze.leftContent,children:[jsx(View,{style:[ze.iconContainer,{backgroundColor:l.cardHover}],children:jsx(Do,{size:20,color:l.foreground,strokeWidth:2})}),jsxs(View,{style:ze.textContainer,children:[jsx(Text,{style:[ze.title,{color:l.foreground}],children:t}),jsx(Text,{style:[ze.subtitle,{color:l.foregroundMuted}],children:o})]})]}),jsx(View,{style:ze.rightContent,children:jsx(View,{style:ze.paymentIcons,children:n?.map(s=>{let u=s.icon_urls.find(w=>w.format==="png")?.url||s.icon_urls.find(w=>w.format==="svg")?.url;return jsx(ue,{uri:H(u),width:32,height:20,borderRadius:4},s.name)})})})]})}var ze=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,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 Vt({onPress:e,title:t,subtitle:o,badge:n}){let{colors:l}=V();return jsx(TouchableOpacity,{onPress:e,activeOpacity:.7,style:[Fe.container,{backgroundColor:l.card}],children:jsxs(View,{style:Fe.leftContent,children:[jsxs(View,{style:[Fe.iconContainer,{backgroundColor:l.cardHover}],children:[jsx(_t,{size:20,color:l.foreground,strokeWidth:2}),n!==void 0&&n>0&&jsx(View,{style:[Fe.badge,{backgroundColor:l.primary}],children:jsx(Text,{style:Fe.badgeText,children:n>99?"99+":n})})]}),jsxs(View,{style:Fe.textContainer,children:[jsx(Text,{style:[Fe.title,{color:l.foreground}],children:t}),jsx(Text,{style:[Fe.subtitle,{color:l.foregroundMuted}],children:o})]})]})})}var Fe=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:16,paddingHorizontal:12,borderRadius:12,marginHorizontal:16},leftContent:{flexDirection:"row",alignItems:"center",gap:12,flex:1},iconContainer:{width:36,height:36,borderRadius:8,alignItems:"center",justifyContent:"center",position:"relative"},badge:{position:"absolute",top:-4,right:-4,minWidth:18,height:18,borderRadius:9,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 Yt({value:e,size:t=180,logoUri:o,logoSize:n=40,logoBackgroundColor:l}){let{colors:s,isDark:u}=V(),w=u?"#1a1a1a":"#ffffff",p=u?"#ffffff":"#000000",k=l||w;return jsxs(View,{style:[ur.container,{width:t,height:t}],children:[jsx(rn,{value:e||"placeholder",size:t,backgroundColor:w,color:p,ecl:"H",quietZone:4}),o&&jsx(View,{style:[ur.logoContainer,{width:n+12,height:n+12,backgroundColor:k,borderRadius:(n+12)/2}],children:jsx(ue,{uri:o,width:n,height:n,borderRadius:n/2})})]})}var ur=StyleSheet.create({container:{alignItems:"center",justifyContent:"center",position:"relative"},logoContainer:{position:"absolute",alignItems:"center",justifyContent:"center"}});function fr(e){let t=e.split("/"),o=t[t.length-1];return o&&o.length>10?`${o.slice(0,6)}...${o.slice(-3)}`:o||""}function pn(e){let o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()],n=e.getDate(),l=e.getFullYear(),s=e.getHours(),u=e.getMinutes(),w=s>=12?"pm":"am";s=s%12,s=s||12;let p=u<10?`0${u}`:u;return `${o} ${n}, ${l} at ${s}:${p}${w}`}function Zt({visible:e,status:t,tokenIconUrl:o,explorerUrl:n,completionExplorerUrl:l,date:s,amountUsd:u,onClose:w}){let{colors:p}=V(),k=useRef(new Animated.Value(0)).current,[r,T]=useState(false),a=t==="pending"||t==="waiting"||t==="delayed",S=t==="succeeded";useEffect(()=>{if(a&&e){let x=Animated.loop(Animated.timing(k,{toValue:1,duration:1e3,easing:Easing.linear,useNativeDriver:true}));return x.start(),()=>x.stop()}else k.setValue(0);},[a,e,k]);let W=k.interpolate({inputRange:[0,1],outputRange:["0deg","360deg"]}),j=()=>{n&&Linking.openURL(n);},E=()=>{l&&Linking.openURL(l);};return jsx(Y,{visible:e,onClose:w,closeOnBackdropPress:true,showHandle:false,children:jsxs(View,{style:$.container,children:[jsx(TouchableOpacity,{style:$.closeButton,onPress:w,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(De,{size:20,color:p.foregroundMuted,strokeWidth:2})}),jsxs(View,{style:$.iconContainer,children:[o?jsx(Image,{source:{uri:H(o)},style:$.tokenIcon}):jsx(View,{style:[$.tokenIcon,{backgroundColor:p.cardHover}]}),jsx(View,{style:[$.statusBadge,{backgroundColor:a?"#F97316":"#22C55E"}],children:a?jsx(Animated.View,{style:{transform:[{rotate:W}]},children:jsx(qt,{size:16,color:"#fff",strokeWidth:2.5})}):jsx(oe,{size:16,color:"#fff",strokeWidth:3})})]}),jsx(Text,{style:[$.title,{color:p.foreground}],children:a?"Deposit Processing":"Deposit Complete"}),u!==void 0&&jsxs(Text,{style:[$.amount,{color:p.foreground}],children:["$",u.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})]}),s&&jsx(Text,{style:[$.date,{color:p.foregroundMuted}],children:pn(s)}),jsx(Text,{style:[$.subtitle,{color:p.foregroundMuted}],children:a?"This usually takes less than a minute.":"Your account has been credited successfully!"}),S&&(n||l)&&jsxs(View,{style:$.detailsSection,children:[jsx(View,{style:[$.divider,{backgroundColor:p.border}]}),jsxs(TouchableOpacity,{style:$.detailsToggle,onPress:()=>T(!r),children:[jsx(Text,{style:[$.detailsToggleText,{color:p.foregroundMuted}],children:r?"See less":"See more details"}),r?jsx(dt,{size:18,color:p.foregroundMuted,strokeWidth:2}):jsx(ce,{size:18,color:p.foregroundMuted,strokeWidth:2})]}),r&&jsxs(View,{style:$.txButtonsContainer,children:[n&&jsxs(TouchableOpacity,{style:[$.txButton,{backgroundColor:p.card,borderColor:p.border}],onPress:j,children:[jsx(Text,{style:[$.txLabel,{color:p.foreground}],children:"Deposit tx"}),jsx(Text,{style:[$.txHash,{color:p.foregroundMuted}],children:fr(n)}),jsx(Ye,{size:16,color:p.foregroundMuted,strokeWidth:2})]}),l&&jsxs(TouchableOpacity,{style:[$.txButton,{backgroundColor:p.card,borderColor:p.border}],onPress:E,children:[jsx(Text,{style:[$.txLabel,{color:p.foreground}],children:"Completion tx"}),jsx(Text,{style:[$.txHash,{color:p.foregroundMuted}],children:fr(l)}),jsx(Ye,{size:16,color:p.foregroundMuted,strokeWidth:2})]})]})]})]})})}var $=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},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"}});var Pt=(e,t)=>`${t}:${e}`,hn=e=>{let[t,o]=e.split(":");return {chainType:t,chainId:o}};function oo({externalUserId:e,publishableKey:t,recipientAddress:o,destinationChainType:n,destinationChainId:l,destinationTokenAddress:s,destinationTokenSymbol:u,onExecutionsChange:w,onDepositSuccess:p,onDepositError:k}){let{colors:r}=V(),[T,a]=useState("USDC"),[S,W]=useState("solana:mainnet"),[j,E]=useState([]),[x,L]=useState(true),[F,m]=useState([]),[G,U]=useState(true),[re,ne]=useState(false),[P,xe]=useState(false),[Ue,ke]=useState(false),[be,se]=useState(false),[Se,fe]=useState([]),[Oe,wt]=useState(new Map),[Ne]=useState(()=>new Date),[qe,ge]=useState(null),[mo,At]=useState(false),[_e,yo]=useState(null),[rt,nt]=useState(false),it=new Map;F.forEach(g=>{g.chains.forEach(R=>{let z=`${R.chain_type}:${R.chain_id}`;it.has(z)||it.set(z,R);});});let wo=Array.from(it.values()),Et=hn(S),zt=wo.find(g=>g.chain_type===Et.chainType&&g.chain_id===Et.chainId)?.chain_type||"ethereum",Ie=bt(j,zt)?.address||"";useEffect(()=>{async function g(){try{U(!0),ge(null);let R=await bo(t);if(m(R.data),R.data.length>0){let z=R.data[0];if(a(z.symbol),z.chains.length>0){let O=z.chains[0];W(Pt(O.chain_id,O.chain_type));}}}catch(R){console.error("Error fetching supported tokens:",R),ge("Failed to load supported tokens"),k?.({message:"Failed to load supported tokens",error:R});}finally{U(false);}}g();},[t,k]),useEffect(()=>{async function g(){try{L(!0),ge(null);let R=await kt({external_user_id:e,recipient_address:o,destination_chain_type:n,destination_chain_id:l,destination_token_address:s},t);E(R.data);}catch(R){console.error("Error fetching wallets:",R),ge("Failed to load wallets"),k?.({message:"Failed to load wallets",error:R});}finally{L(false);}}g();},[e,o,n,l,s,t,k]),useEffect(()=>{if(!e||!Ne)return;let g=setInterval(async()=>{try{let R=await Tt(e,t),z=null;for(let O of R.data){let We=O.created_at?new Date(O.created_at):null;if(!We||We<=Ne)continue;let Me=Oe.get(O.id);if(!Me){z=O;break}if(["pending","waiting","delayed"].includes(Me)&&O.status==="succeeded"){z=O;break}}if(z){let O=z;fe(We=>{let Me=We.findIndex(Ct=>Ct.id===O.id);if(Me>=0){let Ct=[...We];return Ct[Me]=O,Ct}else return [...We,O]}),wt(We=>{let Me=new Map(We);return Me.set(O.id,O.status),Me}),yo(O),At(!0),O.status==="succeeded"&&p?.({message:"Deposit completed successfully",executionId:O.id}),w?.([...Se,O]);}}catch(R){console.error("Error polling executions:",R),k?.({message:"Failed to check deposit status",error:R});}},5e3);return ()=>clearInterval(g)},[e,t,Ne,Oe,Se,w,p,k]),useEffect(()=>{if(!F.length)return;let g=F.find(z=>z.symbol===T);if(!g||g.chains.length===0)return;if(!g.chains.some(z=>Pt(z.chain_id,z.chain_type)===S)){let z=g.chains[0];W(Pt(z.chain_id,z.chain_type));}},[T,F,S]);let st=F.find(g=>g.symbol===T),Ft=st?.chains||[],ve=Ft.find(g=>Pt(g.chain_id,g.chain_type)===S),xo=async()=>{if(Ie)try{Clipboard.setString(Ie),ne(!0),setTimeout(()=>ne(!1),2e3);}catch(g){console.error("Failed to copy:",g);}},at=ve?.estimated_price_impact_percent??0,Ht=ve?.max_slippage_percent??.25,ko=ve?.minimum_deposit_amount_usd??3;if(G)return jsxs(View,{style:i.loadingContainer,children:[jsx(ActivityIndicator,{size:"large",color:r.primary}),jsx(Text,{style:[i.loadingText,{color:r.foregroundMuted}],children:"Loading currencies..."})]});if(qe&&F.length===0)return jsxs(View,{style:i.errorContainer,children:[jsx(Text,{style:[i.errorText,{color:r.error}],children:qe}),jsx(Text,{style:[i.errorHint,{color:r.foregroundMuted}],children:"Please check your network connection and try again."})]});let h=()=>jsxs(Y,{visible:Ue,onClose:()=>ke(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsx(View,{style:i.sheetHeaderSpacer}),jsx(Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Select Token"}),jsx(TouchableOpacity,{onPress:()=>ke(false),style:i.sheetCloseButton,children:jsx(De,{size:20,color:r.foreground,strokeWidth:2})})]}),jsx(ScrollView,{style:i.sheetList,showsVerticalScrollIndicator:false,children:F.map(g=>jsxs(TouchableOpacity,{onPress:()=>{a(g.symbol),ke(false);},style:[i.sheetItem,{backgroundColor:T===g.symbol?r.card:"transparent"}],children:[jsx(Image,{source:{uri:H(te(g,"png"))},style:i.sheetItemIcon}),jsxs(View,{style:i.sheetItemText,children:[jsx(Text,{style:[i.sheetItemTitle,{color:r.foreground}],children:g.symbol}),jsxs(Text,{style:[i.sheetItemSubtitle,{color:r.foregroundMuted}],children:[g.chains.length," network",g.chains.length!==1?"s":""," available"]})]}),T===g.symbol&&jsx(oe,{size:20,color:r.primary,strokeWidth:2})]},g.symbol))})]}),A=()=>jsxs(Y,{visible:be,onClose:()=>se(false),closeOnBackdropPress:true,showHandle:false,children:[jsxs(View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsx(View,{style:i.sheetHeaderSpacer}),jsx(Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Select Network"}),jsx(TouchableOpacity,{onPress:()=>se(false),style:i.sheetCloseButton,children:jsx(De,{size:20,color:r.foreground,strokeWidth:2})})]}),jsx(ScrollView,{style:i.sheetList,showsVerticalScrollIndicator:false,children:Ft.map(g=>{let R=Pt(g.chain_id,g.chain_type),z=S===R;return jsxs(TouchableOpacity,{onPress:()=>{W(R),se(false);},style:[i.sheetItem,{backgroundColor:z?r.card:"transparent"}],children:[jsx(Image,{source:{uri:H(te(g,"png"))},style:i.sheetItemIcon}),jsxs(View,{style:i.sheetItemText,children:[jsx(Text,{style:[i.sheetItemTitle,{color:r.foreground}],children:g.chain_name}),jsxs(Text,{style:[i.sheetItemSubtitle,{color:r.foregroundMuted}],children:["Min deposit: $",g.minimum_deposit_amount_usd]})]}),z&&jsx(oe,{size:20,color:r.primary,strokeWidth:2})]},R)})})]});return jsxs(View,{style:i.container,children:[jsxs(View,{style:i.selectorSection,children:[jsx(Text,{style:[i.selectorLabel,{color:r.foregroundMuted}],children:"Token"}),jsxs(TouchableOpacity,{onPress:()=>ke(true),style:[i.selector,{backgroundColor:r.card}],children:[st&&jsx(Image,{source:{uri:H(te(st,"png"))},style:i.selectorIcon}),jsx(Text,{style:[i.selectorText,{color:r.foreground}],children:T}),jsx(ce,{size:16,color:r.foregroundMuted,strokeWidth:2})]})]}),jsxs(View,{style:i.selectorSection,children:[jsxs(Text,{style:[i.selectorLabel,{color:r.foregroundMuted}],children:["Network"," ",jsxs(Text,{style:i.minDeposit,children:["($",ko," min)"]})]}),jsxs(TouchableOpacity,{onPress:()=>se(true),style:[i.selector,{backgroundColor:r.card}],children:[ve&&jsx(Image,{source:{uri:H(te(ve,"png"))},style:i.selectorIcon}),jsx(Text,{style:[i.selectorText,{color:r.foreground}],numberOfLines:1,children:ve?.chain_name||"Select network"}),jsx(ce,{size:16,color:r.foregroundMuted,strokeWidth:2})]})]}),jsx(View,{style:i.qrContainer,children:jsx(View,{style:[i.qrWrapper,{backgroundColor:r.background,borderColor:r.border}],children:x?jsxs(View,{style:i.qrLoading,children:[jsx(ActivityIndicator,{size:"small",color:r.primary}),jsx(Text,{style:[i.loadingText,{color:r.foregroundMuted}],children:"Loading..."})]}):Ie?jsx(Yt,{value:Ie,size:160,logoUri:H(te(ve,"png")||ie("/icons/networks/png/ethereum.png")),logoSize:40}):jsx(View,{style:i.qrLoading,children:jsx(Text,{style:[i.errorText,{color:r.error}],children:"No address available"})})})}),jsxs(View,{style:i.addressSection,children:[jsxs(View,{style:i.addressHeader,children:[jsx(Text,{style:[i.addressLabel,{color:r.foregroundMuted}],children:"Deposit Address"}),re&&jsxs(View,{style:i.copiedIndicator,children:[jsx(oe,{size:14,color:r.success,strokeWidth:2}),jsx(Text,{style:[i.copiedText,{color:r.success}],children:"Copied"})]})]}),jsx(TouchableOpacity,{onPress:xo,disabled:!Ie||x,activeOpacity:.7,style:[i.addressBox,{backgroundColor:r.card}],children:jsx(Text,{style:[i.addressText,{color:r.foreground}],numberOfLines:2,children:x?"Loading...":Ie||"No address available"})})]}),jsxs(View,{style:[i.detailsCard,{backgroundColor:r.card}],children:[jsxs(TouchableOpacity,{onPress:()=>xe(!P),style:i.detailsHeader,children:[jsxs(View,{style:i.detailsRow,children:[jsx(View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsx(_t,{size:12,color:r.foreground,strokeWidth:2})}),jsxs(Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Processing time:"," ",jsx(Text,{style:{color:r.foreground},children:"< 1 min"})]})]}),jsx(View,{style:i.chevronContainer,children:P?jsx(dt,{size:16,color:r.foregroundMuted,strokeWidth:2}):jsx(ce,{size:16,color:r.foregroundMuted,strokeWidth:2})})]}),P&&jsxs(View,{style:i.detailsContent,children:[jsxs(View,{style:i.detailsRow,children:[jsx(View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsx(Po,{size:12,color:r.foreground,strokeWidth:2})}),jsxs(Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Price impact:"," ",jsxs(Text,{style:{color:r.foreground},children:[at.toFixed(2),"%"]})]}),jsx(TouchableOpacity,{onPress:()=>nt(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ro,{size:14,color:r.foregroundMuted,strokeWidth:2})})]}),jsxs(View,{style:i.detailsRow,children:[jsx(View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsx(or,{size:12,color:r.foreground,strokeWidth:2})}),jsxs(Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Max slippage:"," ",jsxs(Text,{style:{color:r.foreground},children:[Ht.toFixed(2),"%"]})]}),jsx(TouchableOpacity,{onPress:()=>nt(true),hitSlop:{top:10,bottom:10,left:10,right:10},style:{marginLeft:-4},children:jsx(Ro,{size:14,color:r.foregroundMuted,strokeWidth:2})})]}),jsxs(View,{style:i.detailsRow,children:[jsx(View,{style:[i.detailIcon,{backgroundColor:r.cardHover}],children:jsx(rr,{size:12,color:r.foreground,strokeWidth:2})}),jsxs(Text,{style:[i.detailsLabel,{color:r.foregroundMuted}],children:["Need help?"," ",jsx(Text,{style:{color:r.foreground,textDecorationLine:"underline"},children:"Contact support"})]})]})]})]}),jsx(TouchableOpacity,{style:i.termsContainer,children:jsx(Text,{style:[i.termsText,{color:r.foregroundMuted}],children:"Terms apply"})}),h(),A(),jsxs(Y,{visible:rt,onClose:()=>nt(false),closeOnBackdropPress:true,showHandle:true,children:[jsxs(View,{style:[i.sheetHeader,{borderBottomColor:r.border}],children:[jsx(View,{style:i.sheetHeaderSpacer}),jsx(Text,{style:[i.sheetTitle,{color:r.foreground}],children:"Price Impact & Slippage"}),jsx(TouchableOpacity,{onPress:()=>nt(false),style:i.sheetCloseButton,children:jsx(De,{size:20,color:r.foreground,strokeWidth:2})})]}),jsxs(View,{style:i.infoSheetContent,children:[jsxs(View,{style:[i.infoCard,{backgroundColor:r.card}],children:[jsxs(View,{style:i.infoCardHeader,children:[jsx(View,{style:[i.infoCardIcon,{backgroundColor:r.cardHover}],children:jsx(Po,{size:16,color:r.foreground,strokeWidth:2})}),jsx(Text,{style:[i.infoCardTitle,{color:r.foreground}],children:"Price Impact"}),jsxs(Text,{style:[i.infoCardValue,{color:r.foreground}],children:[at.toFixed(2),"%"]})]}),jsx(Text,{style:[i.infoCardDescription,{color:r.foregroundMuted}],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:[i.infoCard,{backgroundColor:r.card}],children:[jsxs(View,{style:i.infoCardHeader,children:[jsx(View,{style:[i.infoCardIcon,{backgroundColor:r.cardHover}],children:jsx(nr,{size:16,color:r.foreground,strokeWidth:2})}),jsx(Text,{style:[i.infoCardTitle,{color:r.foreground}],children:"Max Slippage"}),jsxs(Text,{style:[i.infoCardValue,{color:r.foreground}],children:[Ht.toFixed(2),"%"]})]}),jsx(Text,{style:[i.infoCardDescription,{color:r.foregroundMuted}],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."})]})]})]}),_e&&jsx(Zt,{visible:mo,status:_e.status,tokenIconUrl:_e.destination_token_metadata?.icon_urls?.find(g=>g.format==="png")?.url||_e.destination_token_metadata?.icon_url||te(st,"png"),explorerUrl:_e.explorer_url,completionExplorerUrl:_e.destination_explorer_url,onClose:()=>At(false)})]})}var i=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,borderRadius:16,borderWidth:1},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:{paddingHorizontal:12,paddingVertical:16,borderRadius:8},addressText:{fontSize:12,fontFamily:"monospace"},detailsCard:{borderRadius:8,padding:4,marginBottom:16},detailsHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,paddingLeft:8,paddingRight:24},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:{maxHeight:400,paddingTop:8},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 ro({currency:e,isSelected:t,onSelect:o}){let{colors:n}=V();return jsxs(TouchableOpacity,{onPress:()=>o(e.currency_code),activeOpacity:.7,style:[Ze.container,{backgroundColor:n.card}],children:[jsxs(View,{style:Ze.leftContent,children:[jsx(View,{style:[Ze.iconContainer,{backgroundColor:n.background}],children:jsx(Image,{source:{uri:H(te(e,"png"))},style:Ze.icon})}),jsxs(View,{style:Ze.textContainer,children:[jsx(Text,{style:[Ze.name,{color:n.foreground}],children:e.name}),jsx(Text,{style:[Ze.code,{color:n.foregroundMuted}],children:e.currency_code.toUpperCase()})]})]}),t&&jsx(oe,{size:16,color:n.foreground,strokeWidth:2})]})}var Ze=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,borderRadius: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 Lt({title:e,currencies:t,selectedCurrency:o,onSelect:n}){let{colors:l}=V();return t.length===0?null:jsxs(View,{children:[jsx(View,{style:wr.headerContainer,children:jsx(Text,{style:[wr.title,{color:l.foregroundMuted}],children:e})}),t.map(s=>jsx(ro,{currency:s,isSelected:o.toLowerCase()===s.currency_code.toLowerCase(),onSelect:n},s.currency_code))]})}var wr=StyleSheet.create({headerContainer:{paddingHorizontal:12,paddingBottom:8,paddingTop:4},title:{fontSize:14,fontWeight:"500"}});function io({open:e,onOpenChange:t,currencies:o,preferredCurrencyCodes:n,selectedCurrency:l,onSelectCurrency:s}){let{colors:u}=V(),[w,p]=useState(""),k=n.map(E=>o.find(x=>x.currency_code.toLowerCase()===E.toLowerCase())).filter(E=>E!==void 0),r=o.filter(E=>!n.includes(E.currency_code.toLowerCase())),T=E=>{if(!w)return E;let x=w.toLowerCase();return E.filter(L=>L.name.toLowerCase().includes(x)||L.currency_code.toLowerCase().includes(x))},a=T(k),S=T(r),W=E=>{s(E),t(false),p("");},j=()=>{t(false),p("");};return jsxs(Y,{visible:e,onClose:j,closeOnBackdropPress:true,showHandle:false,children:[jsx(de,{title:"Currency",showBack:false,onClose:j}),jsx(View,{style:et.searchContainer,children:jsx(TextInput,{style:[et.searchInput,{backgroundColor:u.card,color:u.foreground}],value:w,onChangeText:p,placeholder:"Search",placeholderTextColor:u.foregroundMuted})}),jsx(ScrollView,{style:et.listContainer,showsVerticalScrollIndicator:false,children:jsxs(View,{style:et.listContent,children:[jsx(Lt,{title:"Popular currencies",currencies:a,selectedCurrency:l,onSelect:W}),a.length>0&&S.length>0&&jsx(View,{style:et.sectionSpacer}),jsx(Lt,{title:"All currencies",currencies:S,selectedCurrency:l,onSelect:W}),a.length===0&&S.length===0&&jsx(View,{style:et.noResultsContainer,children:jsx(Text,{style:[et.noResultsText,{color:u.foregroundMuted}],children:"No currencies found"})})]})})]})}var et=StyleSheet.create({searchContainer:{marginTop:8,paddingHorizontal:16,paddingBottom:12},searchInput:{padding:16,borderRadius:12,fontSize:14},listContainer:{height:400,paddingHorizontal:12},listContent:{paddingBottom:24,minHeight:400},sectionSpacer:{height:8},noResultsContainer:{paddingVertical:32,alignItems:"center"},noResultsText:{fontSize:14}});var Pn=[100,500,1e3];function kr(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 ao({externalUserId:e,publishableKey:t,view:o,onViewChange:n,maxAmountUsd:l=5e4,destinationTokenSymbol:s="USDC",recipientAddress:u,destinationChainType:w,destinationChainId:p,destinationTokenAddress:k,onDepositSuccess:r,onDepositError:T}){let{colors:a}=V(),[S,W]=useState("500.00"),[j,E]=useState("usd"),[x,L]=useState([]),[F,m]=useState(false),[G,U]=useState(null),[re,ne]=useState("amount"),[P,xe]=useState(null),[Ue,ke]=useState([]),[be,se]=useState(true),[Se,fe]=useState(60),[Oe,wt]=useState([]),[Ne,qe]=useState([]),[ge,mo]=useState(null),[At,_e]=useState(false),[yo,rt]=useState(false),[nt,it]=useState(false),[wo,Et]=useState(null),Co=o??re,zt=Oe.find(h=>h.currency_code.toLowerCase()===j.toLowerCase()),Qo=useCallback(h=>{ne(h),h==="quotes"?n?.(h,x.length):n?.(h);},[x.length,n]);useEffect(()=>{async function h(){try{let A=await kt({external_user_id:e,recipient_address:u,destination_chain_type:w,destination_chain_id:p,destination_token_address:k},t);ke(A.data);}catch(A){console.error("Error fetching wallets:",A),U("Failed to load wallet addresses");}finally{se(false);}}h();},[e,u,w,p,k,t]),useEffect(()=>{async function h(){try{let A=await _o(t);wt(A.data),qe(A.preferred||[]);}catch(A){console.error("Error fetching fiat currencies:",A);}}h();},[t]),useEffect(()=>{let h=parseFloat(S);if(isNaN(h)||h<=0){L([]);return}if(j.toLowerCase()==="usd"&&h>l){L([]),U(`Maximum amount is ${kr("usd")}${l.toLocaleString()}`);return}let A=setTimeout(()=>{Ie(h);},500);return ()=>clearTimeout(A)},[S,j,l,t]);let Ie=async h=>{m(true),U(null);try{let A={country_code:"US",destination_currency_code:"usdc_polygon",source_amount:h.toString(),source_currency_code:j.toLowerCase()},g=await To(A,t);if(L(g.data),g.data.length>0){let R=g.data.reduce((z,O)=>O.destination_amount>z.destination_amount?O:z);xe(R);}fe(60);}catch(A){console.error("Failed to fetch quotes:",A),U("Failed to fetch quotes. Please try again."),L([]);}finally{m(false);}};useEffect(()=>{if(x.length===0)return;let h=setInterval(()=>{fe(A=>{if(A<=1){let g=parseFloat(S);return !isNaN(g)&&g>0&&Ie(g),60}return A-1});},1e3);return ()=>clearInterval(h)},[x.length,S]);let st=h=>{(/^\d*\.?\d{0,2}$/.test(h)||h==="")&&W(h);},Ft=h=>{W(h.toFixed(2));},ve=()=>P?P.destination_amount.toFixed(2):"0.00",xo=async()=>{if(P)try{let h=bt(Ue,"ethereum");if(!h?.address){U("Wallet address not available");return}let A={service_provider:P.service_provider,country_code:P.country_code.toUpperCase(),destination_currency_code:P.destination_currency_code,source_currency_code:P.source_currency_code,wallet_address:h.address,source_amount:S},g=await So(A,t);mo({provider:P,sourceCurrency:j,sourceAmount:S}),Et(g.widget_url),it(!0);}catch(h){console.error("Failed to create session:",h),U("Failed to start payment flow"),T?.({message:"Failed to start payment flow",error:h});}},at=kr(j),Ht=()=>{it(false),Qo("onramp"),r?.({message:"Payment flow completed",executionId:ge?.sessionId});},ko=()=>jsx(Rn,{visible:nt,onClose:Ht,url:wo,providerName:P?.service_provider_display_name||"Complete Payment",colors:a});return Co==="amount"?jsxs(Fragment,{children:[jsxs(View,{style:d.amountViewContainer,children:[jsxs(ScrollView,{style:d.scrollContainer,contentContainerStyle:d.scrollContent,showsVerticalScrollIndicator:false,keyboardShouldPersistTaps:"handled",bounces:false,children:[jsx(View,{style:d.currencySelector,children:jsxs(TouchableOpacity,{onPress:()=>_e(true),style:[d.currencyButton,{backgroundColor:a.card}],children:[zt&&jsx(Image,{source:{uri:H(te(zt,"png"))},style:d.currencyIcon}),jsx(Text,{style:[d.currencyText,{color:a.foreground}],children:j.toUpperCase()}),jsx(ce,{size:16,color:a.foregroundMuted,strokeWidth:2})]})}),jsx(io,{open:At,onOpenChange:_e,currencies:Oe,preferredCurrencyCodes:Ne,selectedCurrency:j,onSelectCurrency:h=>{E(h.toLowerCase());}}),jsxs(View,{style:d.amountContainer,children:[jsxs(View,{style:d.amountInputRow,children:[jsx(Text,{style:[d.currencySymbol,{color:a.foreground}],children:at}),jsx(TextInput,{style:[d.amountInput,{color:a.foreground}],value:S,onChangeText:st,keyboardType:"decimal-pad",placeholder:"0",placeholderTextColor:a.foregroundMuted})]}),F?jsx(ActivityIndicator,{size:"small",color:a.primary}):jsxs(Text,{style:[d.usdcPreview,{color:a.foregroundMuted}],children:["\u2248 ",ve()," ",s]})]}),jsx(View,{style:d.quickAmounts,children:Pn.map(h=>jsx(TouchableOpacity,{onPress:()=>Ft(h),style:[d.quickAmountButton,{backgroundColor:a.card},parseFloat(S)===h&&{borderColor:a.primary,borderWidth:2}],children:jsxs(Text,{style:[d.quickAmountText,{color:a.foreground}],children:[at,h.toLocaleString()]})},h))}),jsxs(View,{style:d.providerSection,children:[jsxs(View,{style:d.providerHeader,children:[jsx(Text,{style:[d.providerLabel,{color:a.foreground}],children:"Provider"}),x.length>0&&!F&&jsxs(Text,{style:[d.refreshText,{color:a.foregroundMuted}],children:["Refreshing in ",Se,"s"]})]}),jsx(TouchableOpacity,{onPress:()=>rt(true),disabled:F||x.length===0,style:[d.providerButton,{backgroundColor:a.card},(F||x.length===0)&&d.disabled],children:F?jsxs(View,{style:d.providerLoading,children:[jsx(ActivityIndicator,{size:"small",color:a.foregroundMuted}),jsx(Text,{style:[d.loadingText,{color:a.foregroundMuted}],children:"Finding best rates..."})]}):P?jsxs(View,{style:d.providerContent,children:[jsxs(View,{style:d.providerInfo,children:[jsx(Text,{style:[d.autoPickedText,{color:a.foregroundMuted}],children:"Auto-picked for you"}),jsxs(View,{style:d.providerRow,children:[jsx(ue,{uri:H(P.icon_url),width:32,height:32,borderRadius:8}),jsxs(View,{children:[jsx(Text,{style:[d.providerName,{color:a.foreground}],children:P.service_provider_display_name}),jsxs(Text,{style:[d.bestPriceText,{color:a.success}],children:["Best price \u2022 ",P.destination_amount.toFixed(2)," ","USDC"]})]})]})]}),jsx(Ge,{size:20,color:a.foregroundMuted,strokeWidth:2})]}):jsx(Text,{style:[d.noProviderText,{color:a.foregroundMuted}],children:parseFloat(S)>0?"No providers available":"Enter an amount to see providers"})}),G&&jsx(Text,{style:[d.errorText,{color:a.error}],children:G})]}),jsxs(Y,{visible:yo,onClose:()=>rt(false),closeOnBackdropPress:true,showHandle:false,children:[jsx(de,{title:"Select Provider",showBack:false,onClose:()=>rt(false),badge:x.length>0?{count:x.length}:void 0}),jsx(ScrollView,{style:d.providerModalList,showsVerticalScrollIndicator:false,children:jsx(View,{style:d.quotesList,children:[...x].sort((h,A)=>A.destination_amount-h.destination_amount).map((h,A)=>{let g=P?.service_provider===h.service_provider,R=A===0;return jsxs(TouchableOpacity,{onPress:()=>{xe(h),rt(false);},style:[d.quoteItem,{backgroundColor:a.card},g&&{borderColor:a.primary,borderWidth:2}],children:[jsxs(View,{style:d.quoteLeft,children:[jsx(ue,{uri:H(h.icon_url),width:32,height:32,borderRadius:8}),jsxs(View,{children:[jsx(Text,{style:[d.quoteName,{color:a.foreground}],children:h.service_provider_display_name}),R&&jsx(Text,{style:[d.bestPriceLabel,{color:a.success}],children:"\u2713 Best price"})]})]}),jsxs(View,{style:d.quoteRight,children:[jsxs(Text,{style:[d.quoteAmount,{color:a.foreground}],children:[h.destination_amount.toFixed(2)," USDC"]}),jsxs(Text,{style:[d.quoteSource,{color:a.foregroundMuted}],children:["Fee: ",at,h.total_fee.toFixed(2)]})]})]},h.service_provider)})})})]})]}),jsx(View,{style:[d.continueButtonContainer,{backgroundColor:a.background}],children:jsx(TouchableOpacity,{onPress:xo,disabled:F||be||!P||parseFloat(S)<=0,style:[d.continueButton,{backgroundColor:a.primary},(F||be||!P)&&d.disabledButton],children:jsx(Text,{style:d.continueButtonText,children:be?"Loading...":"Continue"})})})]}),ko()]}):Co==="onramp"&&ge?jsxs(View,{style:d.onrampContainer,children:[jsx(ue,{uri:H(ge.provider.icon_url),width:64,height:64,borderRadius:16}),jsxs(Text,{style:[d.onrampTitle,{color:a.foreground}],children:["Complete transaction with ",ge.provider.service_provider_display_name]}),jsx(Text,{style:[d.onrampSubtitle,{color:a.foregroundMuted}],children:"You can close this modal."}),jsxs(View,{style:[d.flowDiagram,{backgroundColor:a.card}],children:[jsxs(View,{style:d.flowStep,children:[jsx(Image,{source:{uri:ie(`/icons/currencies/png/${ge.sourceCurrency.toLowerCase()}.png`)},style:d.flowIconImage}),jsx(Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You use"}),jsx(Text,{style:[d.flowValue,{color:a.foreground}],children:ge.sourceCurrency.toUpperCase()})]}),jsx(Ge,{size:16,color:a.foregroundMuted,strokeWidth:2}),jsxs(View,{style:d.flowStep,children:[jsxs(View,{style:d.flowIconWithBadge,children:[jsx(Image,{source:{uri:ie("/icons/tokens/png/usdc.png")},style:d.flowIconImageNoBadge}),jsx(Image,{source:{uri:ie("/icons/networks/png/polygon.png")},style:[d.flowNetworkBadge,{borderColor:a.background}]})]}),jsx(Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You buy"}),jsx(Text,{style:[d.flowValue,{color:a.foreground}],children:"USDC"})]}),jsx(Ge,{size:16,color:a.foregroundMuted,strokeWidth:2}),jsxs(View,{style:d.flowStep,children:[jsxs(View,{style:d.flowIconWithBadge,children:[jsx(Image,{source:{uri:ie("/icons/tokens/png/usdc.png")},style:d.flowIconImageNoBadge}),jsx(Image,{source:{uri:ie("/icons/networks/png/polygon.png")},style:[d.flowNetworkBadge,{borderColor:a.background}]})]}),jsx(Text,{style:[d.flowLabel,{color:a.foregroundMuted}],children:"You receive"}),jsx(Text,{style:[d.flowValue,{color:a.foreground}],children:s})]})]}),jsx(View,{style:[d.onrampInfoBox,{backgroundColor:a.card}],children:jsx(Text,{style:[d.onrampInfoText,{color:a.foregroundMuted}],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 Rn({visible:e,onClose:t,url:o,providerName:n,colors:l}){return jsxs(Y,{visible:e,onClose:t,closeOnBackdropPress:false,showHandle:false,heightPercent:.92,noPadding:true,children:[jsxs(View,{style:tt.header,children:[jsx(TouchableOpacity,{onPress:t,style:tt.headerButton,hitSlop:{top:10,bottom:10,left:10,right:10},children:jsx(oe,{size:20,color:l.foregroundMuted,strokeWidth:2})}),jsx(Text,{style:[tt.headerTitle,{color:l.foreground}],children:n}),jsx(View,{style:tt.headerSpacer})]}),o&&jsx(View,{style:tt.container,children:jsx(WebView,{source:{uri:o},style:tt.webView,startInLoadingState:true,renderLoading:()=>jsx(View,{style:tt.loading,children:jsx(ActivityIndicator,{size:"large",color:l.primary})})})})]})}var tt=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"}}),d=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,borderRadius: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,borderRadius:8},quickAmountText:{fontSize:14,fontWeight:"500"},providerSection:{marginBottom:24},providerHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:8},providerLabel:{fontSize:12,fontWeight:"500"},refreshText:{fontSize:10},providerButton:{padding:16,borderRadius:12},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},providerName:{fontSize:14,fontWeight:"500"},bestPriceText:{fontSize:11,marginTop:2},noProviderText:{fontSize:14,textAlign:"center"},errorText:{fontSize:12,marginTop:8},continueButtonContainer:{padding:16,paddingBottom:24},continueButton:{paddingVertical:16,borderRadius:12,alignItems:"center"},disabledButton:{opacity:.5},continueButtonText:{color:"#FFFFFF",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:{height:468,paddingHorizontal:12,marginTop:8},quotesList:{gap:8,paddingBottom:24,minHeight:468},quoteItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",padding:12,borderRadius: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},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,borderRadius:7,borderWidth:2},onrampInfoBox:{marginTop:16,padding:16,borderRadius:12,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 An(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 En(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}function uo({execution:e,onPress:t}){let {colors:o}=V(),n=e.status==="pending"||e.status==="waiting"||e.status==="delayed";e.status==="succeeded";let s=H(te(e.destination_token_metadata,"png")||ie("/icons/tokens/png/usdc.png")),u=n?"Deposit Processing":"Deposit Completed",w=An(e.created_at||new Date().toISOString()),p=En(e.source_amount_usd);return jsxs(TouchableOpacity,{onPress:t,activeOpacity:.7,style:[Le.container,{backgroundColor:o.card}],children:[jsxs(View,{style:Le.iconContainer,children:[jsx(Image,{source:{uri:s},style:Le.tokenIcon}),jsx(View,{style:[Le.statusBadge,{backgroundColor:n?"#EAB308":"#22C55E",borderColor:o.card}],children:n?jsx(qt,{size:12,color:"#FFFFFF",strokeWidth:2.5}):jsx(oe,{size:12,color:"#FFFFFF",strokeWidth:3})})]}),jsxs(View,{style:Le.textContainer,children:[jsx(Text,{style:[Le.title,{color:o.foreground}],children:u}),jsx(Text,{style:[Le.dateTime,{color:o.foregroundMuted}],children:w})]}),jsxs(View,{style:Le.rightContainer,children:[jsx(Text,{style:[Le.amount,{color:o.foreground}],children:p}),jsx(Ge,{size:20,color:o.foregroundMuted,strokeWidth:2})]})]})}var Le=StyleSheet.create({container:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:12,borderRadius:12},iconContainer:{position:"relative",marginRight:12},tokenIcon:{width:40,height:40,borderRadius:20},statusBadge:{position:"absolute",bottom:-2,right:-2,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"}});var{height:Un}=Dimensions.get("window");function _r(e,t){let o={solana:"Solana",ethereum:"Ethereum",bitcoin:"Bitcoin"};return e==="ethereum"?{1:"Ethereum",137:"Polygon",8453:"Base",42161:"Arbitrum",10:"Optimism"}[t]||o[e]||e:o[e]||e}function Ir(e,t=6){if(!e)return "\u2014";try{let o=Number(e)/Math.pow(10,t);return o===0?"0.00":o>=1?o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2}):o.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:8,minimumSignificantDigits:2,maximumSignificantDigits:6})}catch{return "0.00"}}function On(e){return e?`$${parseFloat(e).toFixed(2)}`:"$0.00"}var vr=e=>!e||e.length<12?e:`${e.slice(0,12)}...${e.slice(-4)}`;function Dr(e){if(!e)return "";let t=e.indexOf(".");return t===-1?e.toUpperCase():e.slice(0,t).toUpperCase()+e.slice(t)}function Nn(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 fo({visible:e,onClose:t,executions:o,externalUserId:n,publishableKey:l}){let{colors:s}=V(),[u,w]=useState(o),[p,k]=useState(false),[r,T]=useState(null),[a,S]=useState(false),W=useRef(null);useEffect(()=>{if(!e||!n)return;let m=async()=>{k(true);try{let re=[...(await Tt(n,l)).data].sort((ne,P)=>{let xe=ne.created_at?new Date(ne.created_at).getTime():0;return (P.created_at?new Date(P.created_at).getTime():0)-xe});w(re);}catch(U){console.error("Failed to fetch executions:",U),w(o);}finally{k(false);}};m();let G=setInterval(m,1e4);return ()=>clearInterval(G)},[e,n,l,o]),useEffect(()=>{o.length>0&&w(m=>{let G=new Set(m.map(re=>re.id)),U=o.filter(re=>!G.has(re.id));return U.length>0?[...U,...m]:m});},[o]),useEffect(()=>{e||T(null);},[e]);let j=m=>{T(m);},E=()=>{T(null),S(false);},x=()=>{T(null),t();};return jsxs(Y,{visible:e,onClose:x,closeOnBackdropPress:true,showHandle:false,heightPercent:.6,children:[jsx(de,{title:r?"Deposit Details":"Deposit Tracker",onClose:x,showClose:!r,showBack:!!r,onBack:E}),r?(()=>{if(!r)return null;let m=r,G=m.status==="pending"||m.status==="waiting"||m.status==="delayed",U=m.status==="succeeded",re=H(te(m.destination_token_metadata,"png")||ie("/icons/tokens/png/usdc.png")),ne=m.provider_metadata?.details,P=ne?.currencyIn,xe=ne?.currencyOut;P?.currency?.symbol||"USDC";xe?.currency?.symbol||"USDC";let be=Ir(m.source_amount_base_unit,m.source_token_metadata?.decimals),se=Ir(m.destination_amount_base_unit,m.destination_token_metadata?.decimals),Se=On(m.source_amount_usd),fe=_r(m.source_chain_type,m.source_chain_id),Oe=_r(m.destination_chain_type,m.destination_chain_id),wt=()=>{m.explorer_url&&Linking.openURL(m.explorer_url);},Ne=()=>{m.destination_explorer_url&&Linking.openURL(m.destination_explorer_url);};return jsxs(ScrollView,{ref:W,style:y.scrollContainer,contentContainerStyle:y.detailsContent,showsVerticalScrollIndicator:false,children:[jsxs(View,{style:y.iconSection,children:[jsxs(View,{style:y.iconWrapper,children:[jsx(Image,{source:{uri:re},style:y.tokenIcon}),jsx(View,{style:[y.statusBadge,{backgroundColor:G?"#EAB308":"#22C55E",borderColor:s.background}],children:G?jsx(ce,{size:14,color:"#FFFFFF",strokeWidth:2}):jsx(oe,{size:14,color:"#FFFFFF",strokeWidth:2})})]}),jsxs(View,{style:y.statusRow,children:[jsx(View,{style:[y.statusDot,{backgroundColor:G?"#EAB308":"#22C55E"}]}),jsx(Text,{style:[y.statusText,{color:s.foreground}],children:G?"Processing":"Completed"})]}),jsx(Text,{style:[y.dateText,{color:s.foregroundMuted}],children:Nn(m.created_at||new Date().toISOString())})]}),jsxs(View,{style:[y.card,{backgroundColor:s.card}],children:[jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Amount Sent"}),jsxs(Text,{style:[y.cardValue,{color:s.foreground}],children:[be," ",Dr(m.source_currency)]})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Amount Received"}),jsxs(Text,{style:[y.cardValue,{color:s.foreground}],children:[se," ",Dr(m.destination_currency)]})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"USD Value"}),jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:Se})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Source Network"}),jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:fe})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]}),jsxs(View,{style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Destination Network"}),jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:Oe})]})]}),jsxs(TouchableOpacity,{onPress:()=>{let qe=!a;S(qe),qe?setTimeout(()=>{W.current?.scrollToEnd({animated:true});},100):W.current?.scrollTo({y:0,animated:true});},style:y.toggleButton,activeOpacity:.7,children:[jsx(Text,{style:[y.toggleText,{color:s.foregroundMuted}],children:a?"See less":"See more details"}),a?jsx(dt,{size:14,color:s.foregroundMuted,strokeWidth:2}):jsx(ce,{size:14,color:s.foregroundMuted,strokeWidth:2})]}),a&&jsxs(View,{style:[y.card,{backgroundColor:s.card}],children:[m.explorer_url&&jsxs(View,{children:[jsxs(TouchableOpacity,{onPress:wt,style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Deposit Tx"}),jsxs(View,{style:y.cardRowRight,children:[jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:vr(m.transaction_hash)}),jsx(Ye,{size:14,color:s.foregroundMuted,strokeWidth:2})]})]}),jsx(View,{style:[y.cardDivider,{backgroundColor:s.border}]})]}),m.destination_explorer_url&&U&&jsxs(TouchableOpacity,{onPress:Ne,style:y.cardRow,children:[jsx(Text,{style:[y.cardLabel,{color:s.foregroundMuted}],children:"Completion Tx"}),jsxs(View,{style:y.cardRowRight,children:[jsx(Text,{style:[y.cardValue,{color:s.foreground}],children:vr(m.destination_transaction_hashes[0])}),jsx(Ye,{size:14,color:s.foregroundMuted,strokeWidth:2})]})]})]})]})})():jsx(ScrollView,{style:y.scrollContainer,contentContainerStyle:y.scrollContent,showsVerticalScrollIndicator:false,children:u.length===0?jsxs(View,{style:y.emptyContainer,children:[jsx(Text,{style:[y.emptyText,{color:s.foregroundMuted}],children:"No deposits yet"}),jsx(Text,{style:[y.emptySubtext,{color:s.foregroundMuted}],children:"Your deposit history will appear here"})]}):jsx(View,{style:y.executionsList,children:u.map(m=>jsx(uo,{execution:m,onPress:()=>j(m)},m.id))})})]})}var y=StyleSheet.create({scrollContainer:{maxHeight:Un*.7,paddingTop:16},scrollContent:{paddingHorizontal:16,paddingBottom:16},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 Bt(e,t=true){let[o,n]=useState(null),[l,s]=useState(null),[u,w]=useState(false),[p,k]=useState(false),[r,T]=useState(null),[a,S]=useState(null);useEffect(()=>{!t||o||(w(true),Io().then(x=>{n(x),T(null);}).catch(x=>{T(x instanceof Error?x:new Error(String(x)));}).finally(()=>{w(false);}));},[t,o]),useEffect(()=>{!t||!e||l||(k(true),St(e).then(x=>{s(x),S(null);}).catch(x=>{S(x instanceof Error?x:new Error(String(x)));}).finally(()=>{k(false);}));},[t,e,l]);let W=u||p,j=r||a||null,E=null;if(o&&l){let x=l.blocked_country_codes||[],L=o.alpha2.toUpperCase();E=!x.some(F=>F.toUpperCase()===L);}return {isAllowed:E,alpha2:o?.alpha2?.toLowerCase()??null,country:o?.country??null,isLoading:W,error:j}}var ot={transferCrypto:{title:"Transfer Crypto",subtitle:"No limit \u2022 Instant"},depositWithCard:{title:"Deposit with Card",subtitle:"$50,000 limit \u2022 2 min"},depositTracker:{title:"Deposit Tracker",subtitle:"Track your deposit progress"}};function Yn({visible:e,onClose:t,externalUserId:o,publishableKey:n,modalTitle:l="Deposit",destinationTokenSymbol:s,recipientAddress:u,destinationChainType:w,destinationChainId:p,destinationTokenAddress:k,hideDepositTracker:r=false,onDepositSuccess:T,onDepositError:a}){let{colors:S}=V(),[W,j]=useState([]),[E,x]=useState(false),[L,F]=useState(false),[m,G]=useState(false),[U,re]=useState(null),[ne,P]=useState("amount"),{isAllowed:xe,isLoading:Ue}=Bt(n,e);useEffect(()=>{e&&!U&&St(n).then(re).catch(console.error);},[e,U,n]);let ke=()=>{t();},be=W.filter(fe=>fe.status==="pending"||fe.status==="waiting").length,se=Ue||e&&!U,Se=xe===false;return jsxs(Y,{visible:e,onClose:ke,closeOnBackdropPress:false,showHandle:false,children:[jsx(de,{title:l,showBack:false,onClose:ke}),se&&jsx(View,{style:Be.centeredContainer,children:jsx(ActivityIndicator,{size:"large",color:S.primary})}),!se&&Se&&jsxs(View,{style:Be.centeredContainer,children:[jsx(View,{style:[Be.iconContainer,{backgroundColor:S.cardHover}],children:jsx($t,{size:32,color:S.foreground,strokeWidth:1.5})}),jsx(Text,{style:[Be.blockedTitle,{color:S.foreground}],children:"No Tokens Available"}),jsx(Text,{style:[Be.blockedDescription,{color:S.foreground,opacity:.7}],children:"There are no supported tokens available from your current location."})]}),!se&&!Se&&jsxs(View,{style:Be.optionsContainer,children:[jsx(It,{onPress:()=>F(true),title:ot.transferCrypto.title,subtitle:ot.transferCrypto.subtitle,featuredTokens:U?.transfer_crypto?.networks}),jsx(Dt,{onPress:()=>G(true),title:ot.depositWithCard.title,subtitle:ot.depositWithCard.subtitle,paymentNetworks:U?.payment_networks?.networks}),!r&&jsx(Vt,{onPress:()=>x(true),title:ot.depositTracker.title,subtitle:ot.depositTracker.subtitle,badge:be>0?be:void 0})]}),jsx(fo,{visible:E,onClose:()=>x(false),executions:W,externalUserId:o,publishableKey:n}),jsxs(Y,{visible:L,onClose:()=>F(false),closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsx(de,{title:ot.transferCrypto.title,showBack:false,onClose:()=>F(false)}),jsx(ScrollView,{style:Be.transferScrollContainer,contentContainerStyle:Be.scrollContent,showsVerticalScrollIndicator:false,children:jsx(oo,{externalUserId:o,publishableKey:n,recipientAddress:u,destinationChainType:w,destinationChainId:p,destinationTokenAddress:k,destinationTokenSymbol:s,onExecutionsChange:j,onDepositSuccess:T,onDepositError:a})})]}),jsxs(Y,{visible:m,onClose:()=>{G(false),P("amount");},closeOnBackdropPress:false,showHandle:false,heightPercent:.9,children:[jsx(de,{title:`Deposit ${s||"USDC"}`,showBack:ne==="onramp",onBack:()=>P("amount"),onClose:()=>{G(false),P("amount");}}),jsx(View,{style:Be.buyWithCardContainer,children:jsx(ao,{externalUserId:o,publishableKey:n,destinationTokenSymbol:s,recipientAddress:u,destinationChainType:w,destinationChainId:p,destinationTokenAddress:k,onDepositSuccess:T,onDepositError:a,view:ne,onViewChange:fe=>P(fe)})})]})]})}function go({theme:e="auto",...t}){return jsx(xt,{mode:e,children:jsx(Yn,{...t})})}var Be=StyleSheet.create({optionsContainer:{paddingTop:8,paddingBottom:24,gap:8},transferScrollContainer:{flex:1},scrollContent:{paddingBottom:24},buyWithCardContainer:{flex:1},centeredContainer:{alignItems:"center",justifyContent:"center",paddingVertical:48,paddingHorizontal:16,minHeight:200},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}});StyleSheet.create({base:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:12,gap:8},text:{fontWeight:"600",textAlign:"center"},fullWidth:{width:"100%"},disabled:{opacity:.5}});StyleSheet.create({icon:{backgroundColor:"transparent"}});var ii=()=>new QueryClient({defaultOptions:{queries:{staleTime:6e4,retry:1}}}),Lr=createContext(null);function si({children:e,publishableKey:t,config:o}){let[n]=useState(()=>ii()),[l,s]=useState(false),[u,w]=useState(null),p=useColorScheme(),k=useRef(false);k.current||(Ot({publishableKey:t}),k.current=true);let r=useMemo(()=>{let L=o?.appearance||"dark";return L==="auto"?p==="dark"?"dark":"light":L},[o?.appearance,p]);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.'),Ot({publishableKey:t});},[t]);let T=useRef(null),a=useRef(null),S=useCallback(L=>{console.log("[UnifoldProvider] beginDeposit called with:",L),a.current&&(clearTimeout(a.current),a.current=null),T.current&&(console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit."),T.current.reject({message:"Deposit cancelled - new deposit started",code:"DEPOSIT_SUPERSEDED"}),T.current=null);let F=new Promise((m,G)=>{T.current={resolve:m,reject:G};});return w(L),s(true),F},[]),W=useCallback(()=>{T.current&&(T.current.reject({message:"Deposit cancelled by user",code:"DEPOSIT_CANCELLED"}),T.current=null),s(false),a.current=setTimeout(()=>{w(null),a.current=null;},200);},[]),j=useCallback(L=>{console.log("[UnifoldProvider] Deposit success:",L),u?.onSuccess&&u.onSuccess(L),T.current&&(T.current.resolve(L),T.current=null);},[u]),E=useCallback(L=>{console.error("[UnifoldProvider] Deposit error:",L),u?.onError&&u.onError(L),T.current&&(T.current.reject(L),T.current=null);},[u]),x=useMemo(()=>({publishableKey:t,beginDeposit:S,closeDeposit:W}),[t,S,W]);return jsx(QueryClientProvider,{client:n,children:jsx(Lr.Provider,{value:x,children:jsxs(xt,{mode:r,children:[e,u&&jsx(go,{visible:l,onClose:W,publishableKey:t,modalTitle:o?.modalTitle,externalUserId:u.externalUserId,destinationChainType:u.destinationChainType,destinationChainId:u.destinationChainId,destinationTokenSymbol:u.destinationTokenSymbol,recipientAddress:u.recipientAddress,destinationTokenAddress:u.destinationTokenAddress,hideDepositTracker:o?.hideDepositTracker,onDepositSuccess:j,onDepositError:E,theme:r})]})})})}function ai(){let e=useContext(Lr);if(!e)throw new Error("useUnifold must be used within UnifoldProvider");return e}
2
+ export{si as UnifoldProvider,Jo as setDevApiUrl,Bt as useAllowedCountry,ai as useUnifold};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unifold/connect-react-native",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "Unifold Connect React Native SDK - Crypto deposit and onramp for React Native/Expo",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",