@unifold/ui-react 0.1.68 → 0.1.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3,9 +3,9 @@ import {
3
3
  useState as useState40,
4
4
  useEffect as useEffect34,
5
5
  useLayoutEffect as useLayoutEffect2,
6
- useCallback as useCallback8,
7
- useRef as useRef12,
8
- useMemo as useMemo13
6
+ useCallback as useCallback10,
7
+ useRef as useRef13,
8
+ useMemo as useMemo14
9
9
  } from "react";
10
10
  import { ChevronRight as ChevronRight18, MapPinOff as MapPinOff2, AlertTriangle as AlertTriangle3, Bitcoin, DollarSign as DollarSign3 } from "lucide-react";
11
11
 
@@ -579,13 +579,16 @@ function GeoRestrictionScreen({ methodName, message }) {
579
579
  }
580
580
 
581
581
  // src/components/deposits/BuyWithCard.tsx
582
+ import * as React5 from "react";
582
583
  import { useState as useState10, useEffect as useEffect6, useRef as useRef2 } from "react";
584
+ import { useQuery as useQuery3 } from "@tanstack/react-query";
583
585
  import { ChevronDown as ChevronDown2, ChevronRight } from "lucide-react";
584
586
  import {
585
587
  getOnrampQuotes,
586
588
  getOnrampSessionStartUrl,
587
589
  getWalletByChainType,
588
590
  getFiatCurrencies,
591
+ getFiatExchangeRates,
589
592
  getTokenMetadata,
590
593
  getIconUrlWithCdn,
591
594
  getPreferredIconUrl as getPreferredIconUrl2,
@@ -2595,13 +2598,25 @@ function BuyWithCard({
2595
2598
  wallets: externalWallets,
2596
2599
  assetCdnUrl,
2597
2600
  hideDepositFlowInfo = false,
2598
- hideDisplayDescription = false
2601
+ hideDisplayDescription = false,
2602
+ prefilledAmountUsd
2599
2603
  }) {
2600
2604
  const { colors: colors2, fonts, components } = useTheme();
2601
- const [amount, setAmount] = useState10("");
2605
+ const cleanedPrefilledAmountUsd = React5.useMemo(() => {
2606
+ if (!prefilledAmountUsd) return "";
2607
+ return prefilledAmountUsd.replace(/[^0-9.]/g, "");
2608
+ }, [prefilledAmountUsd]);
2609
+ const parsedPrefilledAmountUsd = React5.useMemo(() => {
2610
+ const parsed = parseFloat(cleanedPrefilledAmountUsd);
2611
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
2612
+ }, [cleanedPrefilledAmountUsd]);
2613
+ const shouldAutoConvertPrefilledRef = useRef2(!!cleanedPrefilledAmountUsd);
2614
+ const [amount, setAmount] = useState10(() => cleanedPrefilledAmountUsd);
2602
2615
  const [currency, setCurrency] = useState10("usd");
2603
2616
  const [hasManualCurrencySelection, setHasManualCurrencySelection] = useState10(false);
2604
- const [hasManualAmountEntry, setHasManualAmountEntry] = useState10(false);
2617
+ const [hasManualAmountEntry, setHasManualAmountEntry] = useState10(
2618
+ () => !!cleanedPrefilledAmountUsd
2619
+ );
2605
2620
  const [showCurrencyModal, setShowCurrencyModal] = useState10(false);
2606
2621
  const [quotes, setQuotes] = useState10([]);
2607
2622
  const [quotesLoading, setQuotesLoading] = useState10(false);
@@ -2658,6 +2673,71 @@ function BuyWithCard({
2658
2673
  const [preferredCurrencyCodes, setPreferredCurrencyCodes] = useState10([]);
2659
2674
  const [currenciesLoading, setCurrenciesLoading] = useState10(true);
2660
2675
  const [destinationToken, setDestinationToken] = useState10(null);
2676
+ useEffect6(() => {
2677
+ const hasPrefilledAmount = !!cleanedPrefilledAmountUsd;
2678
+ shouldAutoConvertPrefilledRef.current = hasPrefilledAmount;
2679
+ if (!hasPrefilledAmount) return;
2680
+ setAmount(cleanedPrefilledAmountUsd);
2681
+ setHasManualAmountEntry(true);
2682
+ }, [cleanedPrefilledAmountUsd]);
2683
+ const { data: fiatExchangeRatesResponse, isLoading: isFiatExchangeRatesLoading } = useQuery3({
2684
+ queryKey: ["fiat-exchange-rates", publishableKey],
2685
+ staleTime: 3e4,
2686
+ refetchInterval: 3e4,
2687
+ queryFn: async () => {
2688
+ try {
2689
+ return await getFiatExchangeRates({}, publishableKey);
2690
+ } catch (error) {
2691
+ console.error("Error fetching fiat exchange rates:", error);
2692
+ return { base_currency: "usd", rates: {} };
2693
+ }
2694
+ }
2695
+ });
2696
+ const fiatExchangeRates = fiatExchangeRatesResponse?.rates ?? {};
2697
+ const convertAmountBetweenCurrencies = React5.useCallback(
2698
+ (rawAmount, fromCurrencyCode, toCurrencyCode) => {
2699
+ const parsedAmount = parseFloat(rawAmount);
2700
+ if (!Number.isFinite(parsedAmount) || parsedAmount <= 0) return null;
2701
+ const fromCode = fromCurrencyCode.toLowerCase();
2702
+ const toCode = toCurrencyCode.toLowerCase();
2703
+ const fromRate = fromCode === "usd" ? 1 : fiatExchangeRates[fromCode];
2704
+ const toRate = toCode === "usd" ? 1 : fiatExchangeRates[toCode];
2705
+ if (!Number.isFinite(fromRate) || fromRate <= 0) return null;
2706
+ if (!Number.isFinite(toRate) || toRate <= 0) return null;
2707
+ const usdAmount = parsedAmount / fromRate;
2708
+ return parseFloat((usdAmount * toRate).toFixed(2)).toString();
2709
+ },
2710
+ [fiatExchangeRates]
2711
+ );
2712
+ const getConvertedPrefilledAmount = React5.useCallback(
2713
+ (targetCurrencyCode) => {
2714
+ if (!parsedPrefilledAmountUsd) return null;
2715
+ const normalizedTargetCurrency = targetCurrencyCode.toLowerCase();
2716
+ const rate = normalizedTargetCurrency === "usd" ? 1 : fiatExchangeRates[normalizedTargetCurrency];
2717
+ if (!Number.isFinite(rate) || rate <= 0) return null;
2718
+ return parseFloat((parsedPrefilledAmountUsd * rate).toFixed(2)).toString();
2719
+ },
2720
+ [parsedPrefilledAmountUsd, fiatExchangeRates]
2721
+ );
2722
+ useEffect6(() => {
2723
+ if (!cleanedPrefilledAmountUsd || !shouldAutoConvertPrefilledRef.current) return;
2724
+ const convertedAmount = getConvertedPrefilledAmount(currency);
2725
+ if (!convertedAmount) {
2726
+ if (isFiatExchangeRatesLoading) return;
2727
+ const targetCurrency = currency.toLowerCase();
2728
+ if (targetCurrency !== "usd") {
2729
+ setCurrency("usd");
2730
+ }
2731
+ return;
2732
+ }
2733
+ setAmount(convertedAmount);
2734
+ setHasManualAmountEntry(true);
2735
+ }, [
2736
+ cleanedPrefilledAmountUsd,
2737
+ currency,
2738
+ getConvertedPrefilledAmount,
2739
+ isFiatExchangeRatesLoading
2740
+ ]);
2661
2741
  const depositWalletId = defaultToken ? getWalletByChainType(wallets, defaultToken.destination_token_metadata.chain_type)?.id : void 0;
2662
2742
  const { executions, isPolling, showWaitingUi } = useDepositPolling({
2663
2743
  userId,
@@ -2688,6 +2768,7 @@ function BuyWithCard({
2688
2768
  }, [publishableKey]);
2689
2769
  useEffect6(() => {
2690
2770
  if (hasManualCurrencySelection) return;
2771
+ if (hasManualAmountEntry && !shouldAutoConvertPrefilledRef.current) return;
2691
2772
  if (fiatCurrencies.length === 0 || !userIpInfo?.alpha2) return;
2692
2773
  const userCountryCode = userIpInfo.alpha2;
2693
2774
  const matchingCurrency = fiatCurrencies.find((c) => c.country_codes.includes(userCountryCode));
@@ -2706,7 +2787,15 @@ function BuyWithCard({
2706
2787
  const prevCurrencyRef = useRef2(null);
2707
2788
  useEffect6(() => {
2708
2789
  if (fiatCurrencies.length === 0) return;
2790
+ if (shouldAutoConvertPrefilledRef.current) {
2791
+ prevCurrencyRef.current = currency;
2792
+ return;
2793
+ }
2709
2794
  if (prevCurrencyRef.current !== null && prevCurrencyRef.current !== currency) {
2795
+ if (hasManualAmountEntry) {
2796
+ prevCurrencyRef.current = currency;
2797
+ return;
2798
+ }
2710
2799
  const currentCurrency = fiatCurrencies.find(
2711
2800
  (c) => c.currency_code.toLowerCase() === currency.toLowerCase()
2712
2801
  );
@@ -2715,7 +2804,7 @@ function BuyWithCard({
2715
2804
  }
2716
2805
  }
2717
2806
  prevCurrencyRef.current = currency;
2718
- }, [currency]);
2807
+ }, [currency, fiatCurrencies, hasManualAmountEntry]);
2719
2808
  useEffect6(() => {
2720
2809
  async function fetchDestinationToken() {
2721
2810
  try {
@@ -2892,6 +2981,7 @@ function BuyWithCard({
2892
2981
  return () => clearInterval(timer);
2893
2982
  }, [quotes.length, amount]);
2894
2983
  const handleAmountChange = (value) => {
2984
+ shouldAutoConvertPrefilledRef.current = false;
2895
2985
  if (value === "") {
2896
2986
  setAmount(value);
2897
2987
  setHasManualAmountEntry(true);
@@ -2905,6 +2995,7 @@ function BuyWithCard({
2905
2995
  }
2906
2996
  };
2907
2997
  const handleQuickAmount = (quickAmount) => {
2998
+ shouldAutoConvertPrefilledRef.current = false;
2908
2999
  setAmount(quickAmount.toString());
2909
3000
  setHasManualAmountEntry(true);
2910
3001
  };
@@ -3508,8 +3599,43 @@ function BuyWithCard({
3508
3599
  preferredCurrencyCodes,
3509
3600
  selectedCurrency: currency,
3510
3601
  onSelectCurrency: (currencyCode) => {
3511
- setCurrency(currencyCode.toLowerCase());
3602
+ const nextCurrency = currencyCode.toLowerCase();
3603
+ if (nextCurrency === currency.toLowerCase()) {
3604
+ setHasManualCurrencySelection(true);
3605
+ return;
3606
+ }
3607
+ const currentCurrency = currency;
3512
3608
  setHasManualCurrencySelection(true);
3609
+ if (shouldAutoConvertPrefilledRef.current) {
3610
+ const convertedAmount = getConvertedPrefilledAmount(nextCurrency);
3611
+ if (convertedAmount) {
3612
+ setCurrency(nextCurrency);
3613
+ setAmount(convertedAmount);
3614
+ setHasManualAmountEntry(true);
3615
+ } else {
3616
+ if (isFiatExchangeRatesLoading) return;
3617
+ const fallbackUsdAmount = getConvertedPrefilledAmount("usd");
3618
+ setCurrency("usd");
3619
+ if (fallbackUsdAmount) {
3620
+ setAmount(fallbackUsdAmount);
3621
+ setHasManualAmountEntry(true);
3622
+ }
3623
+ }
3624
+ return;
3625
+ }
3626
+ if (hasManualAmountEntry && amount) {
3627
+ const convertedAmount = convertAmountBetweenCurrencies(
3628
+ amount,
3629
+ currentCurrency,
3630
+ nextCurrency
3631
+ );
3632
+ if (convertedAmount) {
3633
+ setCurrency(nextCurrency);
3634
+ setAmount(convertedAmount);
3635
+ }
3636
+ return;
3637
+ }
3638
+ setCurrency(nextCurrency);
3513
3639
  },
3514
3640
  themeClass
3515
3641
  }
@@ -3528,8 +3654,8 @@ function BuyWithCard({
3528
3654
  }
3529
3655
 
3530
3656
  // src/components/deposits/BuyWithApplePay.tsx
3531
- import * as React5 from "react";
3532
- import { useCallback, useEffect as useEffect7, useMemo as useMemo3, useRef as useRef3, useState as useState11 } from "react";
3657
+ import * as React6 from "react";
3658
+ import { useCallback as useCallback2, useEffect as useEffect7, useMemo as useMemo4, useRef as useRef3, useState as useState11 } from "react";
3533
3659
  import { Loader2 as Loader22 } from "lucide-react";
3534
3660
  import {
3535
3661
  createCoinbaseApplePaySession,
@@ -3586,13 +3712,13 @@ function isOnrampTokenFresh(contact) {
3586
3712
  }
3587
3713
 
3588
3714
  // src/hooks/use-coinbase-legal-agreements.ts
3589
- import { useQuery as useQuery3 } from "@tanstack/react-query";
3715
+ import { useQuery as useQuery4 } from "@tanstack/react-query";
3590
3716
  import { getCoinbaseLegalAgreements } from "@unifold/core";
3591
3717
  function useCoinbaseLegalAgreements({
3592
3718
  publishableKey,
3593
3719
  enabled = true
3594
3720
  }) {
3595
- return useQuery3({
3721
+ return useQuery4({
3596
3722
  queryKey: ["unifold", "coinbaseLegalAgreements", publishableKey],
3597
3723
  queryFn: () => getCoinbaseLegalAgreements(publishableKey),
3598
3724
  enabled: enabled && !!publishableKey,
@@ -3605,10 +3731,10 @@ function useCoinbaseLegalAgreements({
3605
3731
  }
3606
3732
 
3607
3733
  // src/hooks/use-apple-pay-initial-screen.ts
3608
- import { useMemo as useMemo2 } from "react";
3734
+ import { useMemo as useMemo3 } from "react";
3609
3735
 
3610
3736
  // src/hooks/use-apple-pay-limits.ts
3611
- import { useQuery as useQuery4 } from "@tanstack/react-query";
3737
+ import { useQuery as useQuery5 } from "@tanstack/react-query";
3612
3738
  import { getCoinbaseApplePayLimits } from "@unifold/core";
3613
3739
  var US_E164_REGEX = /^\+1\d{10}$/;
3614
3740
  function useApplePayLimits({
@@ -3617,7 +3743,7 @@ function useApplePayLimits({
3617
3743
  enabled = true
3618
3744
  }) {
3619
3745
  const phoneValid = US_E164_REGEX.test(phone);
3620
- return useQuery4({
3746
+ return useQuery5({
3621
3747
  queryKey: ["unifold", "applePayLimits", phone, publishableKey],
3622
3748
  queryFn: ({ signal }) => getCoinbaseApplePayLimits(phone, publishableKey, signal),
3623
3749
  enabled: enabled && phoneValid && !!publishableKey,
@@ -3658,7 +3784,7 @@ function useApplePayInitialScreen({
3658
3784
  sessionPhoneVerified,
3659
3785
  isWaiting
3660
3786
  }) {
3661
- const initialStoredSession = useMemo2(() => getStoredApplePaySession(userId), [userId]);
3787
+ const initialStoredSession = useMemo3(() => getStoredApplePaySession(userId), [userId]);
3662
3788
  const phoneVerified = PHONE_REGEX.test(normalizedPhone) && (sessionPhoneVerified || initialStoredSession?.phone === normalizedPhone && !!initialStoredSession?.phoneVerifiedAt);
3663
3789
  const {
3664
3790
  data: applePayLimits,
@@ -3669,7 +3795,7 @@ function useApplePayInitialScreen({
3669
3795
  publishableKey,
3670
3796
  enabled: phoneVerified
3671
3797
  });
3672
- const action = useMemo2(() => {
3798
+ const action = useMemo3(() => {
3673
3799
  if (isWaiting || applePayLimitsLoading) return { kind: "pending" };
3674
3800
  const stored = initialStoredSession;
3675
3801
  const hasUserEmail = !!userEmail && EMAIL_REGEX.test(userEmail);
@@ -3707,7 +3833,7 @@ function useApplePayInitialScreen({
3707
3833
  }
3708
3834
 
3709
3835
  // src/hooks/use-default-onramp-token.ts
3710
- import { useQuery as useQuery5 } from "@tanstack/react-query";
3836
+ import { useQuery as useQuery6 } from "@tanstack/react-query";
3711
3837
  import { getDefaultOnrampToken as getDefaultOnrampToken2 } from "@unifold/core";
3712
3838
  function useDefaultOnrampToken({
3713
3839
  publishableKey,
@@ -3723,7 +3849,7 @@ function useDefaultOnrampToken({
3723
3849
  isLoading,
3724
3850
  isError,
3725
3851
  error
3726
- } = useQuery5({
3852
+ } = useQuery6({
3727
3853
  queryKey: [
3728
3854
  "unifold",
3729
3855
  "defaultOnrampToken",
@@ -3800,7 +3926,7 @@ function parseCoinbasePostMessage(raw) {
3800
3926
  } : void 0
3801
3927
  };
3802
3928
  }
3803
- var BuyWithApplePay = React5.forwardRef(
3929
+ var BuyWithApplePay = React6.forwardRef(
3804
3930
  function BuyWithApplePay2({
3805
3931
  userId,
3806
3932
  publishableKey,
@@ -3871,7 +3997,7 @@ var BuyWithApplePay = React5.forwardRef(
3871
3997
  countryCode: userIpInfo?.alpha2,
3872
3998
  subdivisionCode: userIpInfo?.subdivisionCode ?? void 0
3873
3999
  });
3874
- const depositWallet = useMemo3(() => {
4000
+ const depositWallet = useMemo4(() => {
3875
4001
  const routingChainType = defaultToken?.destination_token_metadata?.chain_type;
3876
4002
  if (!routingChainType) return void 0;
3877
4003
  return getWalletByChainType2(depositWallets ?? [], routingChainType);
@@ -3959,7 +4085,7 @@ var BuyWithApplePay = React5.forwardRef(
3959
4085
  popupRef.current = null;
3960
4086
  };
3961
4087
  }, []);
3962
- React5.useImperativeHandle(
4088
+ React6.useImperativeHandle(
3963
4089
  ref,
3964
4090
  () => ({
3965
4091
  requestBack: () => {
@@ -4001,9 +4127,9 @@ var BuyWithApplePay = React5.forwardRef(
4001
4127
  }),
4002
4128
  [view, emailLocked]
4003
4129
  );
4004
- const normalizedPhone = useMemo3(() => formatPhoneInput(phoneInput), [phoneInput]);
4130
+ const normalizedPhone = useMemo4(() => formatPhoneInput(phoneInput), [phoneInput]);
4005
4131
  const isContactValid = EMAIL_REGEX2.test(email) && PHONE_REGEX2.test(normalizedPhone);
4006
- const storeApplePaySession = useCallback(
4132
+ const storeApplePaySession = useCallback2(
4007
4133
  (patch = {}) => {
4008
4134
  const session = {
4009
4135
  email,
@@ -4015,7 +4141,7 @@ var BuyWithApplePay = React5.forwardRef(
4015
4141
  },
4016
4142
  [email, normalizedPhone, userId]
4017
4143
  );
4018
- const createSessionAndSendOtp = useCallback(async () => {
4144
+ const createSessionAndSendOtp = useCallback2(async () => {
4019
4145
  setView("submitting_session");
4020
4146
  setErrorMessage("");
4021
4147
  try {
@@ -4043,7 +4169,7 @@ var BuyWithApplePay = React5.forwardRef(
4043
4169
  setView("phone_input");
4044
4170
  }
4045
4171
  }, [email, normalizedPhone, publishableKey, storeApplePaySession]);
4046
- const clearUpgradeFields = useCallback(() => {
4172
+ const clearUpgradeFields = useCallback2(() => {
4047
4173
  setSsnLast4("");
4048
4174
  setDobInput("");
4049
4175
  }, []);
@@ -4055,7 +4181,7 @@ var BuyWithApplePay = React5.forwardRef(
4055
4181
  sessionPhoneVerified: verificationSession?.phone?.status === "verified",
4056
4182
  isWaiting: defaultTokenLoading || legalAgreementsLoading || userIpInfoLoading
4057
4183
  });
4058
- const pollLimitUpgradeStatus = useCallback(
4184
+ const pollLimitUpgradeStatus = useCallback2(
4059
4185
  async (signal) => {
4060
4186
  const POLL_INTERVAL_MS4 = 1500;
4061
4187
  const POLL_TIMEOUT_MS = 3e4;
@@ -4117,7 +4243,7 @@ var BuyWithApplePay = React5.forwardRef(
4117
4243
  clearUpgradeFields
4118
4244
  ]
4119
4245
  );
4120
- const startUpgradePolling = useCallback(async () => {
4246
+ const startUpgradePolling = useCallback2(async () => {
4121
4247
  upgradeFlowAbortRef.current?.abort();
4122
4248
  const controller = new AbortController();
4123
4249
  upgradeFlowAbortRef.current = controller;
@@ -4129,7 +4255,7 @@ var BuyWithApplePay = React5.forwardRef(
4129
4255
  }
4130
4256
  }
4131
4257
  }, [pollLimitUpgradeStatus]);
4132
- const applyLimitRouting = useCallback(
4258
+ const applyLimitRouting = useCallback2(
4133
4259
  (nextView, status) => {
4134
4260
  if (nextView === "limit_upgrade_form" && status === "resubmit") {
4135
4261
  setLimitUpgradeError(
@@ -4166,11 +4292,11 @@ var BuyWithApplePay = React5.forwardRef(
4166
4292
  break;
4167
4293
  }
4168
4294
  }, [initialAction, applyLimitRouting, createSessionAndSendOtp]);
4169
- const startVerification = useCallback(async () => {
4295
+ const startVerification = useCallback2(async () => {
4170
4296
  if (!isContactValid) return;
4171
4297
  await createSessionAndSendOtp();
4172
4298
  }, [isContactValid, createSessionAndSendOtp]);
4173
- const submitLimitUpgrade = useCallback(async () => {
4299
+ const submitLimitUpgrade = useCallback2(async () => {
4174
4300
  if (upgradeSubmitting) return;
4175
4301
  try {
4176
4302
  const dob = parseDobInput(dobInput);
@@ -4220,7 +4346,7 @@ var BuyWithApplePay = React5.forwardRef(
4220
4346
  startUpgradePolling,
4221
4347
  clearUpgradeFields
4222
4348
  ]);
4223
- const submitPhoneOtp = useCallback(async () => {
4349
+ const submitPhoneOtp = useCallback2(async () => {
4224
4350
  if (!verificationSession || !clientSecret || phoneCode.length !== 6) return;
4225
4351
  if (otpSubmitting) return;
4226
4352
  setOtpError(null);
@@ -4288,7 +4414,7 @@ var BuyWithApplePay = React5.forwardRef(
4288
4414
  getViewForLimitStatus,
4289
4415
  applyLimitRouting
4290
4416
  ]);
4291
- const prepareSession = useCallback(
4417
+ const prepareSession = useCallback2(
4292
4418
  async (token, amt) => {
4293
4419
  setErrorMessage("");
4294
4420
  if (!destinationChainType || !destinationChainId) {
@@ -5269,7 +5395,7 @@ function LegalDisclaimer({ legalAgreements, loading }) {
5269
5395
  children: [
5270
5396
  "By continuing, you agree to Coinbase's",
5271
5397
  " ",
5272
- agreements.map((a, idx, arr) => /* @__PURE__ */ jsxs11(React5.Fragment, { children: [
5398
+ agreements.map((a, idx, arr) => /* @__PURE__ */ jsxs11(React6.Fragment, { children: [
5273
5399
  /* @__PURE__ */ jsx13(
5274
5400
  "a",
5275
5401
  {
@@ -5545,7 +5671,7 @@ function PayWithExchange({
5545
5671
  }
5546
5672
 
5547
5673
  // src/components/deposits/PayWithCashApp.tsx
5548
- import { useState as useState15, useEffect as useEffect10, useCallback as useCallback2 } from "react";
5674
+ import { useState as useState15, useEffect as useEffect10, useCallback as useCallback3 } from "react";
5549
5675
  import { Copy, Check as Check3, Clock, RefreshCw, Loader2 as Loader23 } from "lucide-react";
5550
5676
  import {
5551
5677
  createCashAppSession,
@@ -5555,7 +5681,7 @@ import {
5555
5681
  } from "@unifold/core";
5556
5682
 
5557
5683
  // src/components/deposits/StyledQRCode.tsx
5558
- import { useEffect as useEffect8, useRef as useRef4, useState as useState13, useMemo as useMemo4 } from "react";
5684
+ import { useEffect as useEffect8, useRef as useRef4, useState as useState13, useMemo as useMemo5 } from "react";
5559
5685
  import QRCodeStyling from "qr-code-styling";
5560
5686
  import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
5561
5687
  function createQRConfig(value, size, imageUrl, imageSize, darkMode) {
@@ -5608,7 +5734,7 @@ function QRCodeSkeleton({ size = 180, darkMode = false }) {
5608
5734
  const spacing = size / gridCount;
5609
5735
  const fillColor = darkMode ? "rgba(255,255,255,0.10)" : "rgba(0,0,0,0.08)";
5610
5736
  const cornerColor = darkMode ? "rgba(255,255,255,0.14)" : "rgba(0,0,0,0.12)";
5611
- const dots = useMemo4(() => {
5737
+ const dots = useMemo5(() => {
5612
5738
  const result = [];
5613
5739
  const cornerSize = 7;
5614
5740
  const centerStart = Math.floor(gridCount / 2) - 2;
@@ -5712,10 +5838,10 @@ function useIsMobileViewport() {
5712
5838
  }
5713
5839
 
5714
5840
  // src/hooks/use-cashapp-limits.ts
5715
- import { useQuery as useQuery6 } from "@tanstack/react-query";
5841
+ import { useQuery as useQuery7 } from "@tanstack/react-query";
5716
5842
  import { getCashAppLimits } from "@unifold/core";
5717
5843
  function useCashAppLimits({ publishableKey, currency = "usd" }) {
5718
- return useQuery6({
5844
+ return useQuery7({
5719
5845
  queryKey: ["unifold", "cashAppLimits", currency, publishableKey],
5720
5846
  queryFn: () => getCashAppLimits(currency, publishableKey),
5721
5847
  enabled: !!publishableKey,
@@ -5731,6 +5857,7 @@ var POLL_INTERVAL_MS2 = 5e3;
5731
5857
  var FALLBACK_MIN_USD = 5;
5732
5858
  var SUGGESTED_AMOUNTS = [25, 50, 100];
5733
5859
  var t3 = i18n.depositModal.cashApp;
5860
+ var sanitizePrefilledUsd = (value) => value?.replace(/[^0-9.]/g, "") ?? "";
5734
5861
  function PayWithCashApp({
5735
5862
  userId,
5736
5863
  publishableKey,
@@ -5745,6 +5872,7 @@ function PayWithCashApp({
5745
5872
  onEvent,
5746
5873
  onDepositSuccess,
5747
5874
  onDepositError,
5875
+ prefilledAmountUsd,
5748
5876
  wallets = []
5749
5877
  }) {
5750
5878
  const { colors: colors2, fonts, components } = useTheme();
@@ -5760,14 +5888,14 @@ function PayWithCashApp({
5760
5888
  const { data: limits, isLoading: limitsLoading } = useCashAppLimits({ publishableKey });
5761
5889
  const minUsd = limits?.minimum_amount ?? FALLBACK_MIN_USD;
5762
5890
  const maxUsd = limits?.maximum_amount ?? null;
5763
- const [amount, setAmount] = useState15("");
5891
+ const [amount, setAmount] = useState15(() => sanitizePrefilledUsd(prefilledAmountUsd));
5764
5892
  const [loading, setLoading] = useState15(false);
5765
5893
  const [session, setSession] = useState15(null);
5766
5894
  const [status, setStatus] = useState15("pending");
5767
5895
  const [error, setError] = useState15(null);
5768
5896
  const [copied, setCopied] = useState15(false);
5769
5897
  const [view, setViewInternal] = useState15(controlledView ?? "amount");
5770
- const setView = useCallback2(
5898
+ const setView = useCallback3(
5771
5899
  (v) => {
5772
5900
  setViewInternal(v);
5773
5901
  onViewChange?.(v);
@@ -5797,7 +5925,7 @@ function PayWithCashApp({
5797
5925
  onDepositSuccess,
5798
5926
  onDepositError
5799
5927
  });
5800
- const handleAmountChange = useCallback2(
5928
+ const handleAmountChange = useCallback3(
5801
5929
  (raw) => {
5802
5930
  const cleaned = raw.replace(/[^0-9.]/g, "");
5803
5931
  const parts = cleaned.split(".");
@@ -5809,7 +5937,7 @@ function PayWithCashApp({
5809
5937
  },
5810
5938
  [onAmountChange]
5811
5939
  );
5812
- const handleCreateSession = useCallback2(async () => {
5940
+ const handleCreateSession = useCallback3(async () => {
5813
5941
  if (!amount || !recipientAddress || !destinationChainType || !destinationChainId || !destinationTokenAddress) {
5814
5942
  setError("Missing required fields");
5815
5943
  return;
@@ -5883,6 +6011,13 @@ function PayWithCashApp({
5883
6011
  return () => clearInterval(interval);
5884
6012
  }, [session, view, status, publishableKey, onDepositSuccess, onDepositError]);
5885
6013
  const [softExpired, setSoftExpired] = useState15(false);
6014
+ useEffect10(() => {
6015
+ if (!prefilledAmountUsd) return;
6016
+ const cleaned = sanitizePrefilledUsd(prefilledAmountUsd);
6017
+ if (!cleaned) return;
6018
+ setAmount(cleaned);
6019
+ onAmountChange?.(cleaned);
6020
+ }, [prefilledAmountUsd, onAmountChange]);
5886
6021
  useEffect10(() => {
5887
6022
  if (!session?.expires_at || view !== "payment") return;
5888
6023
  const expiresMs = new Date(session.expires_at).getTime();
@@ -5897,12 +6032,12 @@ function PayWithCashApp({
5897
6032
  const interval = setInterval(tick, 1e3);
5898
6033
  return () => clearInterval(interval);
5899
6034
  }, [session, view, status]);
5900
- const handleCopy = useCallback2(async (text) => {
6035
+ const handleCopy = useCallback3(async (text) => {
5901
6036
  await navigator.clipboard.writeText(text);
5902
6037
  setCopied(true);
5903
6038
  setTimeout(() => setCopied(false), 2e3);
5904
6039
  }, []);
5905
- const handleRecreate = useCallback2(() => {
6040
+ const handleRecreate = useCallback3(() => {
5906
6041
  setSession(null);
5907
6042
  setStatus("pending");
5908
6043
  setError(null);
@@ -6233,18 +6368,19 @@ function PayWithCashApp({
6233
6368
  }
6234
6369
 
6235
6370
  // src/components/deposits/BankTransfer.tsx
6236
- import { useEffect as useEffect11, useMemo as useMemo5, useState as useState16 } from "react";
6371
+ import { useCallback as useCallback4, useEffect as useEffect11, useMemo as useMemo6, useRef as useRef5, useState as useState16 } from "react";
6237
6372
  import { ChevronRight as ChevronRight3, ExternalLink as ExternalLink3, Landmark } from "lucide-react";
6238
6373
  import {
6239
6374
  DepositEventType as DepositEventType5,
6240
6375
  getIconUrlWithCdn as getIconUrlWithCdn2,
6241
6376
  getOnrampSessionStartUrl as getOnrampSessionStartUrl2,
6377
+ getFiatExchangeRates as getFiatExchangeRates2,
6242
6378
  getWalletByChainType as getWalletByChainType3,
6243
6379
  generatePrefixedKSUID as generatePrefixedKSUID5
6244
6380
  } from "@unifold/core";
6245
6381
 
6246
6382
  // src/hooks/use-bank-transfer-providers.ts
6247
- import { useQuery as useQuery7 } from "@tanstack/react-query";
6383
+ import { useQuery as useQuery8 } from "@tanstack/react-query";
6248
6384
  import { getBankTransferProviders } from "@unifold/core";
6249
6385
  function useBankTransferProviders({
6250
6386
  publishableKey,
@@ -6252,7 +6388,7 @@ function useBankTransferProviders({
6252
6388
  countryCode
6253
6389
  }) {
6254
6390
  const normalizedCountry = countryCode?.toUpperCase();
6255
- const { data: providers, isLoading } = useQuery7({
6391
+ const { data: providers, isLoading } = useQuery8({
6256
6392
  queryKey: ["unifold", "bankTransferProviders", publishableKey, normalizedCountry ?? null],
6257
6393
  queryFn: () => getBankTransferProviders(publishableKey, { countryCode: normalizedCountry }),
6258
6394
  enabled,
@@ -6293,7 +6429,8 @@ function BankTransfer({
6293
6429
  assetCdnUrl,
6294
6430
  onDepositSuccess,
6295
6431
  onEvent,
6296
- onDepositError
6432
+ onDepositError,
6433
+ prefilledAmountUsd
6297
6434
  }) {
6298
6435
  const { colors: colors2, fonts, components } = useTheme();
6299
6436
  const [internalView, setInternalView] = useState16("providers");
@@ -6303,6 +6440,10 @@ function BankTransfer({
6303
6440
  const [requestBase, setRequestBase] = useState16(null);
6304
6441
  const [activeRequest, setActiveRequest] = useState16(null);
6305
6442
  const [amount, setAmount] = useState16("");
6443
+ const [fiatExchangeRates, setFiatExchangeRates] = useState16({
6444
+ usd: 1
6445
+ });
6446
+ const providerSelectionRequestIdRef = useRef5(0);
6306
6447
  const currentView = externalView ?? internalView;
6307
6448
  const setView = (v) => {
6308
6449
  setInternalView(v);
@@ -6327,7 +6468,7 @@ function BankTransfer({
6327
6468
  countryCode: userIpInfo?.alpha2
6328
6469
  });
6329
6470
  const providers = providersResponse?.data ?? [];
6330
- const pollingWalletId = useMemo5(() => {
6471
+ const pollingWalletId = useMemo6(() => {
6331
6472
  if (!defaultToken) return void 0;
6332
6473
  return getWalletByChainType3(
6333
6474
  wallets,
@@ -6348,11 +6489,42 @@ function BankTransfer({
6348
6489
  const currencySymbol = getCurrencySymbol2(sourceCurrency);
6349
6490
  const parsedAmount = parseFloat(amount);
6350
6491
  const amountValid = !!amount && Number.isFinite(parsedAmount) && parsedAmount >= MIN_AMOUNT;
6351
- const displayTokenSymbol = useMemo5(
6492
+ const displayTokenSymbol = useMemo6(
6352
6493
  () => destinationTokenSymbol?.toUpperCase() ?? defaultToken?.destination_token_metadata?.symbol?.toUpperCase() ?? defaultToken?.destination_currency?.toUpperCase() ?? "USDC",
6353
6494
  [destinationTokenSymbol, defaultToken]
6354
6495
  );
6355
- const handleProviderClick = (provider) => {
6496
+ const resolvePrefilledSourceAmount = useCallback4(
6497
+ async (sourceCurrencyCode) => {
6498
+ const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
6499
+ if (!cleanedPrefilled) return "";
6500
+ const prefilledUsd = parseFloat(cleanedPrefilled);
6501
+ if (!Number.isFinite(prefilledUsd) || prefilledUsd <= 0) return "";
6502
+ const sourceCurrency2 = sourceCurrencyCode.toLowerCase();
6503
+ let rate = sourceCurrency2 === "usd" ? 1 : fiatExchangeRates[sourceCurrency2];
6504
+ if ((!rate || rate <= 0) && sourceCurrency2 !== "usd") {
6505
+ try {
6506
+ const response = await getFiatExchangeRates2({}, publishableKey);
6507
+ if (response?.rates) {
6508
+ setFiatExchangeRates((prev) => ({
6509
+ ...prev,
6510
+ ...response.rates,
6511
+ usd: 1
6512
+ }));
6513
+ }
6514
+ const fetchedRate = response.rates?.[sourceCurrency2];
6515
+ if (Number.isFinite(fetchedRate) && fetchedRate > 0) {
6516
+ rate = fetchedRate;
6517
+ }
6518
+ } catch (error) {
6519
+ console.error("Error fetching fiat exchange rates for bank transfer:", error);
6520
+ }
6521
+ }
6522
+ if (!rate || rate <= 0) return sourceCurrency2 === "usd" ? cleanedPrefilled : "";
6523
+ return parseFloat((prefilledUsd * rate).toFixed(2)).toString();
6524
+ },
6525
+ [fiatExchangeRates, prefilledAmountUsd, publishableKey]
6526
+ );
6527
+ const handleProviderClick = async (provider) => {
6356
6528
  if (!provider.enabled) return;
6357
6529
  setSessionError(null);
6358
6530
  if (!defaultToken) {
@@ -6371,6 +6543,7 @@ function BankTransfer({
6371
6543
  });
6372
6544
  return;
6373
6545
  }
6546
+ const requestId = ++providerSelectionRequestIdRef.current;
6374
6547
  setRequestBase({
6375
6548
  service_provider: provider.service_provider,
6376
6549
  country_code: (userIpInfo?.alpha2 || "DE").toUpperCase(),
@@ -6384,7 +6557,10 @@ function BankTransfer({
6384
6557
  payment_method: provider.payment_methods[0]
6385
6558
  });
6386
6559
  setActiveProvider(provider);
6387
- setAmount("100");
6560
+ const convertedPrefilled = await resolvePrefilledSourceAmount(provider.source_currency);
6561
+ if (requestId !== providerSelectionRequestIdRef.current) return;
6562
+ const hasPrefilledAmount = !!prefilledAmountUsd?.replace(/[^0-9.]/g, "");
6563
+ setAmount(hasPrefilledAmount ? convertedPrefilled : "100");
6388
6564
  setView("amount");
6389
6565
  };
6390
6566
  const handleAmountChange = (value) => {
@@ -6482,7 +6658,7 @@ function BankTransfer({
6482
6658
  return /* @__PURE__ */ jsxs15(
6483
6659
  "button",
6484
6660
  {
6485
- onClick: () => handleProviderClick(provider),
6661
+ onClick: () => void handleProviderClick(provider),
6486
6662
  onMouseEnter: () => !disabled && setHoveredId(provider.service_provider),
6487
6663
  onMouseLeave: () => setHoveredId(null),
6488
6664
  disabled,
@@ -7051,7 +7227,7 @@ function DepositExecutionItem({ execution, onClick }) {
7051
7227
  }
7052
7228
 
7053
7229
  // src/components/deposits/buttons/TransferCryptoButton.tsx
7054
- import * as React6 from "react";
7230
+ import * as React7 from "react";
7055
7231
  import { Zap, ChevronRight as ChevronRight5 } from "lucide-react";
7056
7232
  import { jsx as jsx19, jsxs as jsxs17 } from "react/jsx-runtime";
7057
7233
  function TransferCryptoButton({
@@ -7061,9 +7237,9 @@ function TransferCryptoButton({
7061
7237
  featuredTokens
7062
7238
  }) {
7063
7239
  const { colors: colors2, fonts, components } = useTheme();
7064
- const [isHovered, setIsHovered] = React6.useState(false);
7065
- const [isTouchDevice, setIsTouchDevice] = React6.useState(false);
7066
- React6.useEffect(() => {
7240
+ const [isHovered, setIsHovered] = React7.useState(false);
7241
+ const [isTouchDevice, setIsTouchDevice] = React7.useState(false);
7242
+ React7.useEffect(() => {
7067
7243
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
7068
7244
  }, []);
7069
7245
  const sortedTokens = featuredTokens ? [...featuredTokens].sort((a, b) => a.position - b.position) : [];
@@ -7138,7 +7314,7 @@ function TransferCryptoButton({
7138
7314
  }
7139
7315
 
7140
7316
  // src/components/deposits/buttons/DepositWithCardButton.tsx
7141
- import * as React7 from "react";
7317
+ import * as React8 from "react";
7142
7318
  import { CreditCard, ChevronRight as ChevronRight6 } from "lucide-react";
7143
7319
  import { jsx as jsx20, jsxs as jsxs18 } from "react/jsx-runtime";
7144
7320
  function DepositWithCardButton({
@@ -7148,9 +7324,9 @@ function DepositWithCardButton({
7148
7324
  paymentNetworks
7149
7325
  }) {
7150
7326
  const { colors: colors2, fonts, components } = useTheme();
7151
- const [isHovered, setIsHovered] = React7.useState(false);
7152
- const [isTouchDevice, setIsTouchDevice] = React7.useState(false);
7153
- React7.useEffect(() => {
7327
+ const [isHovered, setIsHovered] = React8.useState(false);
7328
+ const [isTouchDevice, setIsTouchDevice] = React8.useState(false);
7329
+ React8.useEffect(() => {
7154
7330
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
7155
7331
  }, []);
7156
7332
  return /* @__PURE__ */ jsxs18(
@@ -7223,7 +7399,7 @@ function DepositWithCardButton({
7223
7399
  }
7224
7400
 
7225
7401
  // src/components/deposits/buttons/PayWithExchangeButton.tsx
7226
- import * as React8 from "react";
7402
+ import * as React9 from "react";
7227
7403
  import { ArrowLeftRight, ChevronRight as ChevronRight7 } from "lucide-react";
7228
7404
  import { jsx as jsx21, jsxs as jsxs19 } from "react/jsx-runtime";
7229
7405
  function PayWithExchangeButton({
@@ -7234,9 +7410,9 @@ function PayWithExchangeButton({
7234
7410
  loading = false
7235
7411
  }) {
7236
7412
  const { colors: colors2, fonts, components } = useTheme();
7237
- const [isHovered, setIsHovered] = React8.useState(false);
7238
- const [isTouchDevice, setIsTouchDevice] = React8.useState(false);
7239
- React8.useEffect(() => {
7413
+ const [isHovered, setIsHovered] = React9.useState(false);
7414
+ const [isTouchDevice, setIsTouchDevice] = React9.useState(false);
7415
+ React9.useEffect(() => {
7240
7416
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
7241
7417
  }, []);
7242
7418
  if (loading) {
@@ -7315,11 +7491,11 @@ function PayWithExchangeButton({
7315
7491
  }
7316
7492
 
7317
7493
  // src/components/deposits/buttons/ConnectExchangeButton.tsx
7318
- import * as React10 from "react";
7494
+ import * as React11 from "react";
7319
7495
  import { Link2, ChevronRight as ChevronRight8 } from "lucide-react";
7320
7496
 
7321
7497
  // src/components/shared/button.tsx
7322
- import * as React9 from "react";
7498
+ import * as React10 from "react";
7323
7499
  import { Slot } from "@radix-ui/react-slot";
7324
7500
  import { cva } from "class-variance-authority";
7325
7501
  import { jsx as jsx22 } from "react/jsx-runtime";
@@ -7348,11 +7524,11 @@ var buttonVariants = cva(
7348
7524
  }
7349
7525
  }
7350
7526
  );
7351
- var Button = React9.forwardRef(
7527
+ var Button = React10.forwardRef(
7352
7528
  ({ className, variant, size, asChild = false, style, ...props }, ref) => {
7353
7529
  const Comp = asChild ? Slot : "button";
7354
7530
  const { components, fonts } = useTheme();
7355
- const themeStyle = React9.useMemo(() => {
7531
+ const themeStyle = React10.useMemo(() => {
7356
7532
  const baseStyle = { ...style };
7357
7533
  if (variant === "default" || !variant) {
7358
7534
  baseStyle.backgroundColor = components.button.primaryBackground;
@@ -7390,9 +7566,9 @@ function ConnectExchangeButton({
7390
7566
  connectedExchange
7391
7567
  }) {
7392
7568
  const { colors: colors2, fonts, components } = useTheme();
7393
- const [isHovered, setIsHovered] = React10.useState(false);
7394
- const [isTouchDevice, setIsTouchDevice] = React10.useState(false);
7395
- React10.useEffect(() => {
7569
+ const [isHovered, setIsHovered] = React11.useState(false);
7570
+ const [isTouchDevice, setIsTouchDevice] = React11.useState(false);
7571
+ React11.useEffect(() => {
7396
7572
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
7397
7573
  }, []);
7398
7574
  const isConnected = connectedExchange != null;
@@ -7532,7 +7708,7 @@ function ConnectExchangeButton({
7532
7708
  }
7533
7709
 
7534
7710
  // src/components/deposits/buttons/DepositTrackerButton.tsx
7535
- import * as React11 from "react";
7711
+ import * as React12 from "react";
7536
7712
  import { Clock as Clock2, ChevronRight as ChevronRight9 } from "lucide-react";
7537
7713
  import { jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
7538
7714
  function DepositTrackerButton({
@@ -7542,9 +7718,9 @@ function DepositTrackerButton({
7542
7718
  badge
7543
7719
  }) {
7544
7720
  const { colors: colors2, fonts, components } = useTheme();
7545
- const [isHovered, setIsHovered] = React11.useState(false);
7546
- const [isTouchDevice, setIsTouchDevice] = React11.useState(false);
7547
- React11.useEffect(() => {
7721
+ const [isHovered, setIsHovered] = React12.useState(false);
7722
+ const [isTouchDevice, setIsTouchDevice] = React12.useState(false);
7723
+ React12.useEffect(() => {
7548
7724
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
7549
7725
  }, []);
7550
7726
  return /* @__PURE__ */ jsxs21(
@@ -7615,14 +7791,14 @@ function DepositTrackerButton({
7615
7791
  }
7616
7792
 
7617
7793
  // src/components/deposits/buttons/CashAppButton.tsx
7618
- import * as React12 from "react";
7794
+ import * as React13 from "react";
7619
7795
  import { ChevronRight as ChevronRight10 } from "lucide-react";
7620
7796
  import { jsx as jsx25, jsxs as jsxs22 } from "react/jsx-runtime";
7621
7797
  function CashAppButton({ onClick, title, subtitle, iconUrl }) {
7622
7798
  const { colors: colors2, fonts, components } = useTheme();
7623
- const [isHovered, setIsHovered] = React12.useState(false);
7624
- const [isTouchDevice, setIsTouchDevice] = React12.useState(false);
7625
- React12.useEffect(() => {
7799
+ const [isHovered, setIsHovered] = React13.useState(false);
7800
+ const [isTouchDevice, setIsTouchDevice] = React13.useState(false);
7801
+ React13.useEffect(() => {
7626
7802
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
7627
7803
  }, []);
7628
7804
  return /* @__PURE__ */ jsxs22(
@@ -7686,7 +7862,7 @@ function CashAppButton({ onClick, title, subtitle, iconUrl }) {
7686
7862
  }
7687
7863
 
7688
7864
  // src/components/deposits/buttons/ApplePayButton.tsx
7689
- import * as React13 from "react";
7865
+ import * as React14 from "react";
7690
7866
  import { ChevronRight as ChevronRight11 } from "lucide-react";
7691
7867
  import { jsx as jsx26, jsxs as jsxs23 } from "react/jsx-runtime";
7692
7868
  function AppleLogo({ className, style }) {
@@ -7711,9 +7887,9 @@ function AppleLogo({ className, style }) {
7711
7887
  }
7712
7888
  function ApplePayButton({ onClick, title, subtitle }) {
7713
7889
  const { colors: colors2, fonts, components } = useTheme();
7714
- const [isHovered, setIsHovered] = React13.useState(false);
7715
- const [isTouchDevice, setIsTouchDevice] = React13.useState(false);
7716
- React13.useEffect(() => {
7890
+ const [isHovered, setIsHovered] = React14.useState(false);
7891
+ const [isTouchDevice, setIsTouchDevice] = React14.useState(false);
7892
+ React14.useEffect(() => {
7717
7893
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
7718
7894
  }, []);
7719
7895
  return /* @__PURE__ */ jsxs23(
@@ -7770,7 +7946,7 @@ function ApplePayButton({ onClick, title, subtitle }) {
7770
7946
  }
7771
7947
 
7772
7948
  // src/components/deposits/buttons/BankTransferButton.tsx
7773
- import * as React14 from "react";
7949
+ import * as React15 from "react";
7774
7950
  import { Landmark as Landmark2, ChevronRight as ChevronRight12 } from "lucide-react";
7775
7951
  import { jsx as jsx27, jsxs as jsxs24 } from "react/jsx-runtime";
7776
7952
  function BankTransferButton({
@@ -7780,9 +7956,9 @@ function BankTransferButton({
7780
7956
  comingSoon = false
7781
7957
  }) {
7782
7958
  const { colors: colors2, fonts, components } = useTheme();
7783
- const [isHovered, setIsHovered] = React14.useState(false);
7784
- const [isTouchDevice, setIsTouchDevice] = React14.useState(false);
7785
- React14.useEffect(() => {
7959
+ const [isHovered, setIsHovered] = React15.useState(false);
7960
+ const [isTouchDevice, setIsTouchDevice] = React15.useState(false);
7961
+ React15.useEffect(() => {
7786
7962
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
7787
7963
  }, []);
7788
7964
  return /* @__PURE__ */ jsxs24(
@@ -7840,7 +8016,7 @@ function BankTransferButton({
7840
8016
  }
7841
8017
 
7842
8018
  // src/components/deposits/buttons/BrowserWalletButton.tsx
7843
- import * as React28 from "react";
8019
+ import * as React29 from "react";
7844
8020
  import { Wallet, ChevronRight as ChevronRight13, Loader2 as Loader24 } from "lucide-react";
7845
8021
  import { getAddressBalances } from "@unifold/core";
7846
8022
 
@@ -7895,7 +8071,7 @@ function collectAllEip6963EthProviders() {
7895
8071
  }
7896
8072
 
7897
8073
  // src/components/deposits/browser-wallets/useDetectedBrowserWallet.ts
7898
- import * as React15 from "react";
8074
+ import * as React16 from "react";
7899
8075
 
7900
8076
  // src/components/deposits/browser-wallets/detectConnectedWallet.ts
7901
8077
  function identifyEthWallet(provider, hint) {
@@ -8046,18 +8222,18 @@ async function detectConnectedBrowserWallet(chainType) {
8046
8222
  // src/components/deposits/browser-wallets/useDetectedBrowserWallet.ts
8047
8223
  function useDetectedBrowserWallet(opts = {}) {
8048
8224
  const { chainType, enabled = true, onDisconnect } = opts;
8049
- const [wallet, setWallet] = React15.useState(null);
8050
- const [isLoading, setIsLoading] = React15.useState(enabled);
8051
- const [eip6963ProviderCount, setEip6963ProviderCount] = React15.useState(0);
8052
- const onDisconnectRef = React15.useRef(onDisconnect);
8225
+ const [wallet, setWallet] = React16.useState(null);
8226
+ const [isLoading, setIsLoading] = React16.useState(enabled);
8227
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React16.useState(0);
8228
+ const onDisconnectRef = React16.useRef(onDisconnect);
8053
8229
  onDisconnectRef.current = onDisconnect;
8054
- React15.useEffect(() => {
8230
+ React16.useEffect(() => {
8055
8231
  const store = getEip6963Store();
8056
8232
  if (!store) return;
8057
8233
  setEip6963ProviderCount(store.getProviders().length);
8058
8234
  return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
8059
8235
  }, []);
8060
- React15.useEffect(() => {
8236
+ React16.useEffect(() => {
8061
8237
  if (!enabled) {
8062
8238
  setWallet(null);
8063
8239
  setIsLoading(false);
@@ -8201,10 +8377,10 @@ async function disconnectInjectedBrowserWallet(wallet) {
8201
8377
  }
8202
8378
 
8203
8379
  // src/resources/icons/MetamaskIcon.tsx
8204
- import * as React16 from "react";
8380
+ import * as React17 from "react";
8205
8381
  import { jsx as jsx28, jsxs as jsxs25 } from "react/jsx-runtime";
8206
8382
  function MetamaskIcon({ size = 24, className, variant = "color" }) {
8207
- const id = React16.useId();
8383
+ const id = React17.useId();
8208
8384
  if (variant === "light" || variant === "dark") {
8209
8385
  return /* @__PURE__ */ jsxs25(
8210
8386
  "svg",
@@ -8326,10 +8502,10 @@ function MetamaskIcon({ size = 24, className, variant = "color" }) {
8326
8502
  }
8327
8503
 
8328
8504
  // src/resources/icons/PhantomIcon.tsx
8329
- import * as React17 from "react";
8505
+ import * as React18 from "react";
8330
8506
  import { jsx as jsx29, jsxs as jsxs26 } from "react/jsx-runtime";
8331
8507
  function PhantomIcon({ size = 24, className, variant = "color" }) {
8332
- const id = React17.useId();
8508
+ const id = React18.useId();
8333
8509
  if (variant === "light") {
8334
8510
  return /* @__PURE__ */ jsx29(
8335
8511
  "svg",
@@ -8397,10 +8573,10 @@ function PhantomIcon({ size = 24, className, variant = "color" }) {
8397
8573
  }
8398
8574
 
8399
8575
  // src/resources/icons/CoinbaseIcon.tsx
8400
- import * as React18 from "react";
8576
+ import * as React19 from "react";
8401
8577
  import { jsx as jsx30, jsxs as jsxs27 } from "react/jsx-runtime";
8402
8578
  function CoinbaseIcon({ size = 24, className, variant = "color" }) {
8403
- const id = React18.useId();
8579
+ const id = React19.useId();
8404
8580
  if (variant === "light") {
8405
8581
  return /* @__PURE__ */ jsxs27(
8406
8582
  "svg",
@@ -8481,10 +8657,10 @@ function CoinbaseIcon({ size = 24, className, variant = "color" }) {
8481
8657
  }
8482
8658
 
8483
8659
  // src/resources/icons/RabbyIcon.tsx
8484
- import * as React19 from "react";
8660
+ import * as React20 from "react";
8485
8661
  import { jsx as jsx31, jsxs as jsxs28 } from "react/jsx-runtime";
8486
8662
  function RabbyIcon({ size = 24, className, variant = "color" }) {
8487
- const id = React19.useId();
8663
+ const id = React20.useId();
8488
8664
  if (variant === "light") {
8489
8665
  return /* @__PURE__ */ jsxs28(
8490
8666
  "svg",
@@ -8832,10 +9008,10 @@ function RabbyIcon({ size = 24, className, variant = "color" }) {
8832
9008
  }
8833
9009
 
8834
9010
  // src/resources/icons/RainbowIcon.tsx
8835
- import * as React20 from "react";
9011
+ import * as React21 from "react";
8836
9012
  import { jsx as jsx32, jsxs as jsxs29 } from "react/jsx-runtime";
8837
9013
  function RainbowIcon({ size = 24, className, variant = "color" }) {
8838
- const id = React20.useId();
9014
+ const id = React21.useId();
8839
9015
  if (variant === "light") {
8840
9016
  return /* @__PURE__ */ jsxs29(
8841
9017
  "svg",
@@ -9250,10 +9426,10 @@ function RainbowIcon({ size = 24, className, variant = "color" }) {
9250
9426
  }
9251
9427
 
9252
9428
  // src/resources/icons/TrustIcon.tsx
9253
- import * as React21 from "react";
9429
+ import * as React22 from "react";
9254
9430
  import { jsx as jsx33, jsxs as jsxs30 } from "react/jsx-runtime";
9255
9431
  function TrustIcon({ size = 24, className, variant = "color" }) {
9256
- const id = React21.useId();
9432
+ const id = React22.useId();
9257
9433
  if (variant === "light") {
9258
9434
  return /* @__PURE__ */ jsx33(
9259
9435
  "svg",
@@ -9337,10 +9513,10 @@ function TrustIcon({ size = 24, className, variant = "color" }) {
9337
9513
  }
9338
9514
 
9339
9515
  // src/resources/icons/OkxIcon.tsx
9340
- import * as React22 from "react";
9516
+ import * as React23 from "react";
9341
9517
  import { jsx as jsx34, jsxs as jsxs31 } from "react/jsx-runtime";
9342
9518
  function OkxIcon({ size = 24, className, variant = "color" }) {
9343
- const id = React22.useId();
9519
+ const id = React23.useId();
9344
9520
  if (variant === "light") {
9345
9521
  return /* @__PURE__ */ jsx34(
9346
9522
  "svg",
@@ -9396,10 +9572,10 @@ function OkxIcon({ size = 24, className, variant = "color" }) {
9396
9572
  }
9397
9573
 
9398
9574
  // src/resources/icons/GlowIcon.tsx
9399
- import * as React23 from "react";
9575
+ import * as React24 from "react";
9400
9576
  import { jsx as jsx35, jsxs as jsxs32 } from "react/jsx-runtime";
9401
9577
  function GlowIcon({ size = 24, className, variant = "color" }) {
9402
- const id = React23.useId();
9578
+ const id = React24.useId();
9403
9579
  if (variant === "light") {
9404
9580
  return /* @__PURE__ */ jsx35(
9405
9581
  "svg",
@@ -9501,10 +9677,10 @@ function GlowIcon({ size = 24, className, variant = "color" }) {
9501
9677
  }
9502
9678
 
9503
9679
  // src/resources/icons/BackpackIcon.tsx
9504
- import * as React24 from "react";
9680
+ import * as React25 from "react";
9505
9681
  import { jsx as jsx36, jsxs as jsxs33 } from "react/jsx-runtime";
9506
9682
  function BackpackIcon({ size = 24, className, variant = "color" }) {
9507
- const id = React24.useId();
9683
+ const id = React25.useId();
9508
9684
  if (variant === "light") {
9509
9685
  return /* @__PURE__ */ jsx36(
9510
9686
  "svg",
@@ -9578,10 +9754,10 @@ function BackpackIcon({ size = 24, className, variant = "color" }) {
9578
9754
  }
9579
9755
 
9580
9756
  // src/resources/icons/SolflareIcon.tsx
9581
- import * as React25 from "react";
9757
+ import * as React26 from "react";
9582
9758
  import { jsx as jsx37, jsxs as jsxs34 } from "react/jsx-runtime";
9583
9759
  function SolflareIcon({ size = 24, className, variant = "color" }) {
9584
- const id = React25.useId();
9760
+ const id = React26.useId();
9585
9761
  if (variant === "light") {
9586
9762
  return /* @__PURE__ */ jsx37(
9587
9763
  "svg",
@@ -9649,10 +9825,10 @@ function SolflareIcon({ size = 24, className, variant = "color" }) {
9649
9825
  }
9650
9826
 
9651
9827
  // src/resources/icons/EthereumIcon.tsx
9652
- import * as React26 from "react";
9828
+ import * as React27 from "react";
9653
9829
  import { jsx as jsx38, jsxs as jsxs35 } from "react/jsx-runtime";
9654
9830
  function EthereumIcon({ size = 24, className, variant = "color" }) {
9655
- const id = React26.useId();
9831
+ const id = React27.useId();
9656
9832
  if (variant === "light") {
9657
9833
  return /* @__PURE__ */ jsxs35(
9658
9834
  "svg",
@@ -9777,10 +9953,10 @@ function EthereumIcon({ size = 24, className, variant = "color" }) {
9777
9953
  }
9778
9954
 
9779
9955
  // src/resources/icons/SolanaIcon.tsx
9780
- import * as React27 from "react";
9956
+ import * as React28 from "react";
9781
9957
  import { jsx as jsx39, jsxs as jsxs36 } from "react/jsx-runtime";
9782
9958
  function SolanaIcon({ size = 24, className, variant = "color" }) {
9783
- const id = React27.useId();
9959
+ const id = React28.useId();
9784
9960
  if (variant === "light") {
9785
9961
  return /* @__PURE__ */ jsx39(
9786
9962
  "svg",
@@ -10031,19 +10207,19 @@ function BrowserWalletButton({
10031
10207
  subtitle = i18n.depositModal.browserWallet.subtitle
10032
10208
  }) {
10033
10209
  const { colors: colors2, fonts, components } = useTheme();
10034
- const [isHovered, setIsHovered] = React28.useState(false);
10035
- const [isTouchDevice, setIsTouchDevice] = React28.useState(false);
10210
+ const [isHovered, setIsHovered] = React29.useState(false);
10211
+ const [isTouchDevice, setIsTouchDevice] = React29.useState(false);
10036
10212
  const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
10037
- const [isConnecting, setIsConnecting] = React28.useState(false);
10038
- const [balanceText, setBalanceText] = React28.useState(null);
10039
- const [isLoadingBalance, setIsLoadingBalance] = React28.useState(false);
10040
- const [isDisconnecting, setIsDisconnecting] = React28.useState(false);
10041
- const onDisconnectRef = React28.useRef(onDisconnect);
10213
+ const [isConnecting, setIsConnecting] = React29.useState(false);
10214
+ const [balanceText, setBalanceText] = React29.useState(null);
10215
+ const [isLoadingBalance, setIsLoadingBalance] = React29.useState(false);
10216
+ const [isDisconnecting, setIsDisconnecting] = React29.useState(false);
10217
+ const onDisconnectRef = React29.useRef(onDisconnect);
10042
10218
  onDisconnectRef.current = onDisconnect;
10043
- React28.useEffect(() => {
10219
+ React29.useEffect(() => {
10044
10220
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
10045
10221
  }, []);
10046
- React28.useEffect(() => {
10222
+ React29.useEffect(() => {
10047
10223
  if (!wallet || !publishableKey) {
10048
10224
  setBalanceText(null);
10049
10225
  return;
@@ -10170,7 +10346,7 @@ function BrowserWalletButton({
10170
10346
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
10171
10347
  };
10172
10348
  const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
10173
- const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React28.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
10349
+ const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React29.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
10174
10350
  size: 36,
10175
10351
  className: "uf-rounded-lg",
10176
10352
  variant: "color"
@@ -10315,7 +10491,7 @@ function BrowserWalletButton({
10315
10491
  }
10316
10492
 
10317
10493
  // src/components/deposits/buttons/StripeLinkButton.tsx
10318
- import * as React29 from "react";
10494
+ import * as React30 from "react";
10319
10495
  import { ChevronRight as ChevronRight14 } from "lucide-react";
10320
10496
  import { jsx as jsx42, jsxs as jsxs39 } from "react/jsx-runtime";
10321
10497
  var t4 = i18n.depositModal.stripeLink;
@@ -10326,9 +10502,9 @@ function StripeLinkButton({
10326
10502
  iconUrl
10327
10503
  }) {
10328
10504
  const { colors: colors2, fonts, components } = useTheme();
10329
- const [isHovered, setIsHovered] = React29.useState(false);
10330
- const [isTouchDevice, setIsTouchDevice] = React29.useState(false);
10331
- React29.useEffect(() => {
10505
+ const [isHovered, setIsHovered] = React30.useState(false);
10506
+ const [isTouchDevice, setIsTouchDevice] = React30.useState(false);
10507
+ React30.useEffect(() => {
10332
10508
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
10333
10509
  }, []);
10334
10510
  return /* @__PURE__ */ jsxs39(
@@ -10398,7 +10574,7 @@ function StripeLinkButton({
10398
10574
  }
10399
10575
 
10400
10576
  // src/components/deposits/stripe-link/PayWithStripeLink.tsx
10401
- import { useState as useState29, useEffect as useEffect24, useCallback as useCallback4, useRef as useRef8 } from "react";
10577
+ import { useState as useState29, useEffect as useEffect24, useCallback as useCallback6, useRef as useRef9 } from "react";
10402
10578
  import {
10403
10579
  Loader2 as Loader25,
10404
10580
  CreditCard as CreditCard3,
@@ -10635,17 +10811,17 @@ import {
10635
10811
  } from "@unifold/core";
10636
10812
 
10637
10813
  // src/components/deposits/stripe-link/use-stripe-onramp.ts
10638
- import { useState as useState28, useEffect as useEffect23, useRef as useRef7, useCallback as useCallback3 } from "react";
10814
+ import { useState as useState28, useEffect as useEffect23, useRef as useRef8, useCallback as useCallback5 } from "react";
10639
10815
  function useStripeOnramp(stripePublishableKey, isDark = false) {
10640
10816
  const [coordinator, setCoordinator] = useState28(null);
10641
10817
  const [isLoading, setIsLoading] = useState28(false);
10642
10818
  const [error, setError] = useState28(null);
10643
- const coordinatorRef = useRef7(null);
10644
- const coordinatorThemeRef = useRef7(null);
10645
- const initPromiseRef = useRef7(null);
10646
- const isDarkRef = useRef7(isDark);
10819
+ const coordinatorRef = useRef8(null);
10820
+ const coordinatorThemeRef = useRef8(null);
10821
+ const initPromiseRef = useRef8(null);
10822
+ const isDarkRef = useRef8(isDark);
10647
10823
  isDarkRef.current = isDark;
10648
- const initialize = useCallback3(() => {
10824
+ const initialize = useCallback5(() => {
10649
10825
  if (coordinatorRef.current) return Promise.resolve(coordinatorRef.current);
10650
10826
  if (initPromiseRef.current) return initPromiseRef.current;
10651
10827
  if (!stripePublishableKey) return Promise.resolve(null);
@@ -10858,6 +11034,8 @@ function PayWithStripeLink({
10858
11034
  destinationChainType,
10859
11035
  destinationChainId,
10860
11036
  destinationTokenAddress,
11037
+ countryCode,
11038
+ subdivisionCode,
10861
11039
  wallets: externalWallets,
10862
11040
  email: emailProp,
10863
11041
  iconUrl,
@@ -10869,14 +11047,14 @@ function PayWithStripeLink({
10869
11047
  }) {
10870
11048
  const { colors: colors2, fonts, components, isDark } = useTheme();
10871
11049
  const [step, setStepInternal] = useState29(controlledStep ?? "amount");
10872
- const setStep = useCallback4(
11050
+ const setStep = useCallback6(
10873
11051
  (s) => {
10874
11052
  setStepInternal(s);
10875
11053
  onStepChange?.(s);
10876
11054
  },
10877
11055
  [onStepChange]
10878
11056
  );
10879
- const stepRef = useRef8(step);
11057
+ const stepRef = useRef9(step);
10880
11058
  stepRef.current = step;
10881
11059
  useEffect24(() => {
10882
11060
  if (controlledStep && controlledStep !== step) {
@@ -10967,20 +11145,20 @@ function PayWithStripeLink({
10967
11145
  const [restoring, setRestoring] = useState29(true);
10968
11146
  const [errorReturnStep, setErrorReturnStep] = useState29("email");
10969
11147
  const [authIntentId, setAuthIntentId] = useState29(null);
10970
- const sdkAuthenticatedRef = useRef8(false);
10971
- const everAuthenticatedRef = useRef8(false);
10972
- const reauthReturnStepRef = useRef8(null);
10973
- const attemptedWalletReauthRef = useRef8(false);
10974
- const pendingAddPaymentRef = useRef8(false);
10975
- const autoOpenedAddPaymentRef = useRef8(false);
10976
- const checkoutGenRef = useRef8(0);
11148
+ const sdkAuthenticatedRef = useRef9(false);
11149
+ const everAuthenticatedRef = useRef9(false);
11150
+ const reauthReturnStepRef = useRef9(null);
11151
+ const attemptedWalletReauthRef = useRef9(false);
11152
+ const pendingAddPaymentRef = useRef9(false);
11153
+ const autoOpenedAddPaymentRef = useRef9(false);
11154
+ const checkoutGenRef = useRef9(0);
10977
11155
  const [stripePaymentUIReady, setStripePaymentUIReady] = useState29(false);
10978
11156
  const [oauthToken, setOauthToken] = useState29(null);
10979
11157
  const [refreshTokenValue, setRefreshTokenValue] = useState29(null);
10980
11158
  const [customerId, setCustomerId] = useState29(null);
10981
- const accessTokenRef = useRef8("");
10982
- const refreshTokenRef = useRef8("");
10983
- const persistSession = useCallback4(
11159
+ const accessTokenRef = useRef9("");
11160
+ const refreshTokenRef = useRef9("");
11161
+ const persistSession = useCallback6(
10984
11162
  (cid, token, refresh, expiresIn, loginEmail) => {
10985
11163
  accessTokenRef.current = token;
10986
11164
  refreshTokenRef.current = refresh;
@@ -10994,8 +11172,8 @@ function PayWithStripeLink({
10994
11172
  },
10995
11173
  [userId, email]
10996
11174
  );
10997
- const refreshInFlightRef = useRef8(null);
10998
- const tryRefreshToken = useCallback4(async () => {
11175
+ const refreshInFlightRef = useRef9(null);
11176
+ const tryRefreshToken = useCallback6(async () => {
10999
11177
  if (refreshInFlightRef.current) return refreshInFlightRef.current;
11000
11178
  const rt = refreshTokenRef.current;
11001
11179
  if (!rt) return null;
@@ -11025,7 +11203,7 @@ function PayWithStripeLink({
11025
11203
  refreshInFlightRef.current = doRefresh();
11026
11204
  return refreshInFlightRef.current;
11027
11205
  }, [publishableKey, customerId, persistSession, userId]);
11028
- const withTokenRefresh = useCallback4(
11206
+ const withTokenRefresh = useCallback6(
11029
11207
  async (fn) => {
11030
11208
  const token = accessTokenRef.current;
11031
11209
  if (!token) {
@@ -11187,8 +11365,8 @@ function PayWithStripeLink({
11187
11365
  );
11188
11366
  const [selectedPaymentToken, setSelectedPaymentToken] = useState29(null);
11189
11367
  const [paymentDisplay, setPaymentDisplay] = useState29(null);
11190
- const selectedTokenSingleUseRef = useRef8(false);
11191
- const selectPaymentToken = useCallback4(
11368
+ const selectedTokenSingleUseRef = useRef9(false);
11369
+ const selectPaymentToken = useCallback6(
11192
11370
  (token) => {
11193
11371
  selectedTokenSingleUseRef.current = !!token.singleUse;
11194
11372
  setSelectedPaymentToken(token.id);
@@ -11200,7 +11378,7 @@ function PayWithStripeLink({
11200
11378
  },
11201
11379
  [customerId]
11202
11380
  );
11203
- const clearSelectedPaymentToken = useCallback4(() => {
11381
+ const clearSelectedPaymentToken = useCallback6(() => {
11204
11382
  selectedTokenSingleUseRef.current = false;
11205
11383
  const persisted = customerId ? getStoredSelectedToken(customerId) : null;
11206
11384
  if (persisted && !persisted.singleUse) {
@@ -11252,7 +11430,9 @@ function PayWithStripeLink({
11252
11430
  {
11253
11431
  tokenAddress: destinationTokenAddress,
11254
11432
  chainId: destinationChainId,
11255
- chainType: destinationChainType
11433
+ chainType: destinationChainType,
11434
+ countryCode,
11435
+ subdivisionCode
11256
11436
  },
11257
11437
  publishableKey
11258
11438
  ).then((token) => {
@@ -11271,10 +11451,17 @@ function PayWithStripeLink({
11271
11451
  return () => {
11272
11452
  cancelled = true;
11273
11453
  };
11274
- }, [publishableKey, destinationTokenAddress, destinationChainId, destinationChainType]);
11454
+ }, [
11455
+ publishableKey,
11456
+ destinationTokenAddress,
11457
+ destinationChainId,
11458
+ destinationChainType,
11459
+ countryCode,
11460
+ subdivisionCode
11461
+ ]);
11275
11462
  const destinationCurrency = stripeDestCurrency;
11276
- const authInnerRef = useRef8(null);
11277
- const paymentInnerRef = useRef8(null);
11463
+ const authInnerRef = useRef9(null);
11464
+ const paymentInnerRef = useRef9(null);
11278
11465
  const [authReady, setAuthReady] = useState29(false);
11279
11466
  if (typeof document !== "undefined" && !authInnerRef.current) {
11280
11467
  authInnerRef.current = document.createElement("div");
@@ -11282,12 +11469,12 @@ function PayWithStripeLink({
11282
11469
  if (typeof document !== "undefined" && !paymentInnerRef.current) {
11283
11470
  paymentInnerRef.current = document.createElement("div");
11284
11471
  }
11285
- const authMountRef = useCallback4((node) => {
11472
+ const authMountRef = useCallback6((node) => {
11286
11473
  if (node && !node.contains(authInnerRef.current)) {
11287
11474
  node.appendChild(authInnerRef.current);
11288
11475
  }
11289
11476
  }, []);
11290
- const paymentMountRef = useCallback4((node) => {
11477
+ const paymentMountRef = useCallback6((node) => {
11291
11478
  if (node && !node.contains(paymentInnerRef.current)) {
11292
11479
  node.appendChild(paymentInnerRef.current);
11293
11480
  }
@@ -11338,8 +11525,8 @@ function PayWithStripeLink({
11338
11525
  });
11339
11526
  const [confirmedSessionId, setConfirmedSessionId] = useState29(null);
11340
11527
  const [sessionStatus, setSessionStatus] = useState29(null);
11341
- const handledTerminalSessionRef = useRef8(null);
11342
- const executionReconciledSessionRef = useRef8(null);
11528
+ const handledTerminalSessionRef = useRef9(null);
11529
+ const executionReconciledSessionRef = useRef9(null);
11343
11530
  const hasExecution = executions.length > 0;
11344
11531
  const isSessionFulfilled = sessionStatus === STRIPE_SESSION_STATUS.FULFILLMENT_COMPLETE || hasExecution;
11345
11532
  const isSessionFailed = !hasExecution && (sessionStatus === STRIPE_SESSION_STATUS.REJECTED || sessionStatus === STRIPE_SESSION_STATUS.EXPIRED);
@@ -11457,7 +11644,7 @@ function PayWithStripeLink({
11457
11644
  sdkAuthenticatedRef.current = false;
11458
11645
  attemptedWalletReauthRef.current = false;
11459
11646
  }, [coordinator]);
11460
- const handleAuthInterrupted = useCallback4(
11647
+ const handleAuthInterrupted = useCallback6(
11461
11648
  (message) => {
11462
11649
  const alreadySignedIn = !!accessTokenRef.current;
11463
11650
  if (alreadySignedIn || emailProp) {
@@ -11470,7 +11657,7 @@ function PayWithStripeLink({
11470
11657
  },
11471
11658
  [emailProp, setStep]
11472
11659
  );
11473
- const reauthenticateSdk = useCallback4(async () => {
11660
+ const reauthenticateSdk = useCallback6(async () => {
11474
11661
  const current = stepRef.current;
11475
11662
  const preAuthSteps = ["email", "register", "auth"];
11476
11663
  reauthReturnStepRef.current = preAuthSteps.includes(current) ? null : current;
@@ -12169,14 +12356,14 @@ function PayWithStripeLink({
12169
12356
  };
12170
12357
  const [quote, setQuote] = useState29(null);
12171
12358
  const [quoteLoading, setQuoteLoading] = useState29(false);
12172
- const quoteTimerRef = useRef8(null);
12359
+ const quoteTimerRef = useRef9(null);
12173
12360
  const [sessionForCheckout, setSessionForCheckoutState] = useState29(null);
12174
- const sessionForCheckoutRef = useRef8(sessionForCheckout);
12361
+ const sessionForCheckoutRef = useRef9(sessionForCheckout);
12175
12362
  const setSessionForCheckout = (s) => {
12176
12363
  sessionForCheckoutRef.current = s;
12177
12364
  setSessionForCheckoutState(s);
12178
12365
  };
12179
- const loadAndSelectPreferredToken = useCallback4(async () => {
12366
+ const loadAndSelectPreferredToken = useCallback6(async () => {
12180
12367
  if (!customerId) return;
12181
12368
  try {
12182
12369
  const existing = await withTokenRefresh(
@@ -12206,7 +12393,7 @@ function PayWithStripeLink({
12206
12393
  };
12207
12394
  const [quoteError, setQuoteError] = useState29(null);
12208
12395
  const [quoteNonce, setQuoteNonce] = useState29(0);
12209
- const quoteNonceAtReviewRef = useRef8(quoteNonce);
12396
+ const quoteNonceAtReviewRef = useRef9(quoteNonce);
12210
12397
  const [purchaseLimit, setPurchaseLimit] = useState29(null);
12211
12398
  const [limitReachedAmount, setLimitReachedAmount] = useState29(null);
12212
12399
  const [requiredStepUp, setRequiredStepUp] = useState29(null);
@@ -14121,7 +14308,7 @@ function PayWithStripeLink({
14121
14308
  }
14122
14309
 
14123
14310
  // src/components/deposits/CoinbaseConnect.tsx
14124
- import { useState as useState30, useEffect as useEffect25, useCallback as useCallback5, useMemo as useMemo7, useRef as useRef9 } from "react";
14311
+ import { useState as useState30, useEffect as useEffect25, useCallback as useCallback7, useMemo as useMemo8, useRef as useRef10 } from "react";
14125
14312
  import {
14126
14313
  ChevronRight as ChevronRight15,
14127
14314
  ChevronDown as ChevronDown4,
@@ -14144,7 +14331,7 @@ import {
14144
14331
  } from "@unifold/core";
14145
14332
 
14146
14333
  // src/hooks/use-project-config.ts
14147
- import { useQuery as useQuery8, keepPreviousData } from "@tanstack/react-query";
14334
+ import { useQuery as useQuery9, keepPreviousData } from "@tanstack/react-query";
14148
14335
  import { getProjectConfig } from "@unifold/core";
14149
14336
  function useProjectConfig({
14150
14337
  publishableKey,
@@ -14156,7 +14343,7 @@ function useProjectConfig({
14156
14343
  data: projectConfig,
14157
14344
  isLoading,
14158
14345
  error
14159
- } = useQuery8({
14346
+ } = useQuery9({
14160
14347
  // Country is part of the key so a region change refetches the region-aware
14161
14348
  // config. Omitted when undefined so callers that don't pass a country keep
14162
14349
  // sharing the base cache entry.
@@ -14175,7 +14362,7 @@ function useProjectConfig({
14175
14362
  }
14176
14363
 
14177
14364
  // src/hooks/use-supported-deposit-tokens.ts
14178
- import { useQuery as useQuery9 } from "@tanstack/react-query";
14365
+ import { useQuery as useQuery10 } from "@tanstack/react-query";
14179
14366
  import {
14180
14367
  getSupportedDepositTokens
14181
14368
  } from "@unifold/core";
@@ -14190,7 +14377,7 @@ function useSupportedDepositTokens(publishableKey, options) {
14190
14377
  ...options?.product_type ? { product_type: options.product_type } : {}
14191
14378
  };
14192
14379
  const hasFilteredOptions = Object.keys(filteredOptions).length > 0;
14193
- return useQuery9({
14380
+ return useQuery10({
14194
14381
  queryKey: [
14195
14382
  "unifold",
14196
14383
  "supportedDepositTokens",
@@ -14211,7 +14398,7 @@ function useSupportedDepositTokens(publishableKey, options) {
14211
14398
  }
14212
14399
 
14213
14400
  // src/hooks/use-integration-transfer-default-token.ts
14214
- import { useQuery as useQuery10 } from "@tanstack/react-query";
14401
+ import { useQuery as useQuery11 } from "@tanstack/react-query";
14215
14402
  import {
14216
14403
  getIntegrationTransferDefaultToken
14217
14404
  } from "@unifold/core";
@@ -14220,7 +14407,7 @@ function useIntegrationTransferDefaultToken({
14220
14407
  publishableKey,
14221
14408
  enabled = true
14222
14409
  }) {
14223
- return useQuery10({
14410
+ return useQuery11({
14224
14411
  queryKey: [
14225
14412
  "unifold",
14226
14413
  "integrationTransferDefaultToken",
@@ -14291,7 +14478,8 @@ function CoinbaseConnect({
14291
14478
  defaultSourceChainType,
14292
14479
  defaultSourceChainId,
14293
14480
  defaultSourceTokenAddress,
14294
- defaultSourceSymbol
14481
+ defaultSourceSymbol,
14482
+ prefilledAmountUsd
14295
14483
  }) {
14296
14484
  const { colors: colors2, fonts, components } = useTheme();
14297
14485
  const { projectConfig } = useProjectConfig({ publishableKey });
@@ -14301,12 +14489,12 @@ function CoinbaseConnect({
14301
14489
  destination_chain_id: destinationChainId,
14302
14490
  destination_chain_type: destinationChainType
14303
14491
  });
14304
- const supportedSymbols = useMemo7(() => {
14492
+ const supportedSymbols = useMemo8(() => {
14305
14493
  const set = /* @__PURE__ */ new Set();
14306
14494
  supportedTokensData?.data.forEach((token) => set.add(token.symbol.toLowerCase()));
14307
14495
  return set;
14308
14496
  }, [supportedTokensData]);
14309
- const stablecoinSymbols = useMemo7(() => {
14497
+ const stablecoinSymbols = useMemo8(() => {
14310
14498
  const set = /* @__PURE__ */ new Set();
14311
14499
  supportedTokensData?.data.forEach((token) => {
14312
14500
  if (token.is_stablecoin) set.add(token.symbol.toLowerCase());
@@ -14339,12 +14527,12 @@ function CoinbaseConnect({
14339
14527
  const [transferDepositWalletId, setTransferDepositWalletId] = useState30(
14340
14528
  void 0
14341
14529
  );
14342
- const exchangeSupportedCurrencies = useMemo7(() => {
14530
+ const exchangeSupportedCurrencies = useMemo8(() => {
14343
14531
  const set = /* @__PURE__ */ new Set();
14344
14532
  selectedExchange?.supported_currencies.forEach((c) => set.add(c.toLowerCase()));
14345
14533
  return set;
14346
14534
  }, [selectedExchange]);
14347
- const defaultTokenParams = useMemo7(
14535
+ const defaultTokenParams = useMemo8(
14348
14536
  () => selectedAsset ? {
14349
14537
  integration_provider: IntegrationProvider.COINBASE,
14350
14538
  source_currency: selectedAsset.currency.toLowerCase(),
@@ -14367,7 +14555,7 @@ function CoinbaseConnect({
14367
14555
  params: defaultTokenParams,
14368
14556
  publishableKey
14369
14557
  });
14370
- const defaultSourceCurrency = useMemo7(
14558
+ const defaultSourceCurrency = useMemo8(
14371
14559
  () => resolveDefaultSourceSymbol(supportedTokensData?.data, {
14372
14560
  defaultSourceChainType,
14373
14561
  defaultSourceChainId,
@@ -14382,7 +14570,7 @@ function CoinbaseConnect({
14382
14570
  defaultSourceSymbol
14383
14571
  ]
14384
14572
  );
14385
- const sortedHoldings = useMemo7(() => {
14573
+ const sortedHoldings = useMemo8(() => {
14386
14574
  const supported = [];
14387
14575
  const unsupported = [];
14388
14576
  holdings.forEach((account) => {
@@ -14402,7 +14590,7 @@ function CoinbaseConnect({
14402
14590
  }
14403
14591
  return [...supported, ...unsupported];
14404
14592
  }, [holdings, supportedSymbols, exchangeSupportedCurrencies, defaultSourceCurrency]);
14405
- const selectedHoldingIsSupported = useMemo7(() => {
14593
+ const selectedHoldingIsSupported = useMemo8(() => {
14406
14594
  if (!selectedHolding) return false;
14407
14595
  const currencyLower = selectedHolding.currency.toLowerCase();
14408
14596
  return (supportedSymbols.size === 0 || supportedSymbols.has(currencyLower)) && (exchangeSupportedCurrencies.size === 0 || exchangeSupportedCurrencies.has(currencyLower));
@@ -14446,10 +14634,10 @@ function CoinbaseConnect({
14446
14634
  useEffect25(() => {
14447
14635
  onExecutionsChange?.(depositExecutions);
14448
14636
  }, [depositExecutions, onExecutionsChange]);
14449
- const pollRef = useRef9(null);
14450
- const popupRef = useRef9(null);
14451
- const viewRef = useRef9(initialView);
14452
- const transitionTo = useCallback5((nextView) => {
14637
+ const pollRef = useRef10(null);
14638
+ const popupRef = useRef10(null);
14639
+ const viewRef = useRef10(initialView);
14640
+ const transitionTo = useCallback7((nextView) => {
14453
14641
  if (nextView === viewRef.current) return;
14454
14642
  setIsTransitioning(true);
14455
14643
  setTimeout(() => {
@@ -14459,7 +14647,7 @@ function CoinbaseConnect({
14459
14647
  setIsTransitioning(false);
14460
14648
  }, 150);
14461
14649
  }, []);
14462
- const tryRefreshToken = useCallback5(
14650
+ const tryRefreshToken = useCallback7(
14463
14651
  async (currentToken) => {
14464
14652
  try {
14465
14653
  const result = await refreshIntegrationToken(currentToken, publishableKey);
@@ -14497,7 +14685,7 @@ function CoinbaseConnect({
14497
14685
  }
14498
14686
  }
14499
14687
  }, []);
14500
- const loadHoldings = useCallback5(
14688
+ const loadHoldings = useCallback7(
14501
14689
  async (token) => {
14502
14690
  setIsLoading(true);
14503
14691
  try {
@@ -14549,7 +14737,7 @@ function CoinbaseConnect({
14549
14737
  if (pollRef.current) clearInterval(pollRef.current);
14550
14738
  };
14551
14739
  }, []);
14552
- const minDepositUsd = useMemo7(() => {
14740
+ const minDepositUsd = useMemo8(() => {
14553
14741
  if (!selectedAsset || !defaultTokenData) return 0;
14554
14742
  const supportedToken = supportedTokensData?.data.find(
14555
14743
  (t14) => t14.symbol.toLowerCase() === selectedAsset.currency.toLowerCase()
@@ -14560,7 +14748,7 @@ function CoinbaseConnect({
14560
14748
  );
14561
14749
  return matchingChain?.minimum_deposit_amount_usd ?? Math.min(...supportedToken.chains.map((c) => c.minimum_deposit_amount_usd));
14562
14750
  }, [selectedAsset, supportedTokensData, defaultTokenData]);
14563
- const estimatedProcessingTime = useMemo7(() => {
14751
+ const estimatedProcessingTime = useMemo8(() => {
14564
14752
  if (!selectedAsset || !defaultTokenData) return null;
14565
14753
  const supportedToken = supportedTokensData?.data.find(
14566
14754
  (t14) => t14.symbol.toLowerCase() === selectedAsset.currency.toLowerCase()
@@ -14614,7 +14802,8 @@ function CoinbaseConnect({
14614
14802
  };
14615
14803
  const handleSelectAsset = (asset) => {
14616
14804
  setSelectedAsset(asset);
14617
- setSendAmount("");
14805
+ const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
14806
+ setSendAmount(cleanedPrefilled);
14618
14807
  transitionTo("enter_amount");
14619
14808
  };
14620
14809
  const handleCreateTransfer = async () => {
@@ -16200,13 +16389,13 @@ function CoinbaseConnect({
16200
16389
  CoinbaseConnect.displayName = "CoinbaseConnect";
16201
16390
 
16202
16391
  // src/hooks/use-exchanges.ts
16203
- import { useQuery as useQuery11 } from "@tanstack/react-query";
16392
+ import { useQuery as useQuery12 } from "@tanstack/react-query";
16204
16393
  import { getExchanges } from "@unifold/core";
16205
16394
  function useExchanges({
16206
16395
  publishableKey,
16207
16396
  enabled = true
16208
16397
  }) {
16209
- const { data: exchanges = [], isLoading } = useQuery11({
16398
+ const { data: exchanges = [], isLoading } = useQuery12({
16210
16399
  queryKey: ["unifold", "exchanges", publishableKey],
16211
16400
  queryFn: () => getExchanges(void 0, publishableKey).then((res) => res.data),
16212
16401
  enabled,
@@ -16218,13 +16407,13 @@ function useExchanges({
16218
16407
  }
16219
16408
 
16220
16409
  // src/hooks/use-apple-pay-providers.ts
16221
- import { useQuery as useQuery12 } from "@tanstack/react-query";
16410
+ import { useQuery as useQuery13 } from "@tanstack/react-query";
16222
16411
  import { getApplePayProviders } from "@unifold/core";
16223
16412
  function useApplePayProviders({
16224
16413
  publishableKey,
16225
16414
  enabled = true
16226
16415
  }) {
16227
- const { data: providers, isLoading } = useQuery12({
16416
+ const { data: providers, isLoading } = useQuery13({
16228
16417
  queryKey: ["unifold", "applePayProviders", publishableKey],
16229
16418
  queryFn: () => getApplePayProviders(publishableKey),
16230
16419
  enabled,
@@ -16289,7 +16478,7 @@ function useAllowedCountry(publishableKey) {
16289
16478
  }
16290
16479
 
16291
16480
  // src/hooks/use-address-validation.ts
16292
- import { useQuery as useQuery13 } from "@tanstack/react-query";
16481
+ import { useQuery as useQuery14 } from "@tanstack/react-query";
16293
16482
  import {
16294
16483
  verifyRecipientAddress
16295
16484
  } from "@unifold/core";
@@ -16303,7 +16492,7 @@ function useAddressValidation({
16303
16492
  refetchOnMount = false
16304
16493
  }) {
16305
16494
  const shouldValidate = enabled && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
16306
- const { data, isLoading, error } = useQuery13({
16495
+ const { data, isLoading, error } = useQuery14({
16307
16496
  queryKey: [
16308
16497
  "unifold",
16309
16498
  "addressValidation",
@@ -16349,7 +16538,7 @@ function useAddressValidation({
16349
16538
  }
16350
16539
 
16351
16540
  // src/components/deposits/TransferCryptoSingleInput.tsx
16352
- import { useState as useState36, useEffect as useEffect30, useMemo as useMemo10 } from "react";
16541
+ import { useState as useState36, useEffect as useEffect30, useMemo as useMemo11 } from "react";
16353
16542
  import {
16354
16543
  ChevronDown as ChevronDown5,
16355
16544
  ChevronUp as ChevronUp3,
@@ -16367,14 +16556,14 @@ import {
16367
16556
  import { useEffect as useEffect27, useState as useState31 } from "react";
16368
16557
 
16369
16558
  // src/components/shared/ThemeStyleInjector.tsx
16370
- import * as React31 from "react";
16559
+ import * as React32 from "react";
16371
16560
  import { jsx as jsx46 } from "react/jsx-runtime";
16372
16561
  function ThemeStyleInjector({
16373
16562
  children,
16374
16563
  className
16375
16564
  }) {
16376
16565
  const { colors: colors2, fonts, mode } = useTheme();
16377
- const cssVars = React31.useMemo(() => {
16566
+ const cssVars = React32.useMemo(() => {
16378
16567
  const hexToHSL = (hex) => {
16379
16568
  hex = hex.replace("#", "");
16380
16569
  const r = parseInt(hex.slice(0, 2), 16) / 255;
@@ -16434,7 +16623,7 @@ function ThemeStyleInjector({
16434
16623
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
16435
16624
  };
16436
16625
  }, [colors2, fonts.regular]);
16437
- React31.useEffect(() => {
16626
+ React32.useEffect(() => {
16438
16627
  if (typeof document === "undefined") return;
16439
16628
  if (fonts.regular) {
16440
16629
  document.documentElement.style.setProperty("--uf-font-family", fonts.regular);
@@ -16708,7 +16897,7 @@ function DepositsModal({
16708
16897
  }
16709
16898
 
16710
16899
  // src/components/deposits/TokenSelectorSheet.tsx
16711
- import { useState as useState32, useMemo as useMemo9, useEffect as useEffect28 } from "react";
16900
+ import { useState as useState32, useMemo as useMemo10, useEffect as useEffect28 } from "react";
16712
16901
  import { ArrowLeft as ArrowLeft2, X as X4 } from "lucide-react";
16713
16902
  import Fuse from "fuse.js";
16714
16903
  import { jsx as jsx49, jsxs as jsxs45 } from "react/jsx-runtime";
@@ -16775,7 +16964,7 @@ function TokenSelectorSheet({
16775
16964
  useEffect28(() => {
16776
16965
  setRecentTokens(getRecentTokens());
16777
16966
  }, []);
16778
- const allOptions = useMemo9(() => {
16967
+ const allOptions = useMemo10(() => {
16779
16968
  const options = [];
16780
16969
  tokens.forEach((token) => {
16781
16970
  token.chains.forEach((chain) => {
@@ -16784,7 +16973,7 @@ function TokenSelectorSheet({
16784
16973
  });
16785
16974
  return options;
16786
16975
  }, [tokens]);
16787
- const quickSelectOptions = useMemo9(() => {
16976
+ const quickSelectOptions = useMemo10(() => {
16788
16977
  const result = [];
16789
16978
  const seen = /* @__PURE__ */ new Set();
16790
16979
  const addOption = (symbol, chainType, chainId, isRecent) => {
@@ -16816,7 +17005,7 @@ function TokenSelectorSheet({
16816
17005
  });
16817
17006
  setRecentTokens(updated);
16818
17007
  };
16819
- const fuse = useMemo9(
17008
+ const fuse = useMemo10(
16820
17009
  () => new Fuse(allOptions, {
16821
17010
  keys: [
16822
17011
  { name: "token.symbol", weight: 2 },
@@ -16829,7 +17018,7 @@ function TokenSelectorSheet({
16829
17018
  }),
16830
17019
  [allOptions]
16831
17020
  );
16832
- const filteredOptions = useMemo9(() => {
17021
+ const filteredOptions = useMemo10(() => {
16833
17022
  if (!searchQuery.trim()) return allOptions;
16834
17023
  const query = searchQuery.trim();
16835
17024
  const results = fuse.search(query);
@@ -17201,7 +17390,7 @@ function TokenSelectorSheet({
17201
17390
  }
17202
17391
 
17203
17392
  // src/hooks/use-default-token.ts
17204
- import { useState as useState33, useEffect as useEffect29, useRef as useRef10 } from "react";
17393
+ import { useState as useState33, useEffect as useEffect29, useRef as useRef11 } from "react";
17205
17394
  var getChainKey = (chainId, chainType) => {
17206
17395
  return `${chainType}:${chainId}`;
17207
17396
  };
@@ -17259,7 +17448,7 @@ function useDefaultToken({
17259
17448
  const [token, setToken] = useState33(null);
17260
17449
  const [chain, setChain] = useState33(null);
17261
17450
  const [initialSelectionDone, setInitialSelectionDone] = useState33(false);
17262
- const appliedDefaultsRef = useRef10("");
17451
+ const appliedDefaultsRef = useRef11("");
17263
17452
  useEffect29(() => {
17264
17453
  if (!tokens.length) return;
17265
17454
  const defaultsKey = `${defaultTokenAddress ?? ""}|${defaultSymbol ?? ""}|${defaultChainType ?? ""}|${defaultChainId ?? ""}`;
@@ -17608,7 +17797,7 @@ function useCopyAddress() {
17608
17797
  }
17609
17798
 
17610
17799
  // src/components/shared/tooltip.tsx
17611
- import * as React32 from "react";
17800
+ import * as React33 from "react";
17612
17801
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
17613
17802
  import { jsx as jsx52 } from "react/jsx-runtime";
17614
17803
  var TooltipProvider = TooltipPrimitive.Provider;
@@ -17616,20 +17805,20 @@ function Tooltip({
17616
17805
  children,
17617
17806
  ...props
17618
17807
  }) {
17619
- const [open, setOpen] = React32.useState(props.defaultOpen ?? false);
17808
+ const [open, setOpen] = React33.useState(props.defaultOpen ?? false);
17620
17809
  const isControlled = props.open !== void 0;
17621
17810
  const isOpen = isControlled ? props.open : open;
17622
17811
  const onOpenChange = isControlled ? props.onOpenChange : (nextOpen) => setOpen(nextOpen);
17623
17812
  return /* @__PURE__ */ jsx52(TooltipContext.Provider, { value: { open: isOpen, onOpenChange }, children: /* @__PURE__ */ jsx52(TooltipPrimitive.Root, { ...props, open: isOpen, onOpenChange, children }) });
17624
17813
  }
17625
- var TooltipContext = React32.createContext({
17814
+ var TooltipContext = React33.createContext({
17626
17815
  open: false,
17627
17816
  onOpenChange: () => {
17628
17817
  }
17629
17818
  });
17630
- var TooltipTrigger = React32.forwardRef(({ onClick, ...props }, ref) => {
17631
- const { open, onOpenChange } = React32.useContext(TooltipContext);
17632
- const handleClick = React32.useCallback(
17819
+ var TooltipTrigger = React33.forwardRef(({ onClick, ...props }, ref) => {
17820
+ const { open, onOpenChange } = React33.useContext(TooltipContext);
17821
+ const handleClick = React33.useCallback(
17633
17822
  (e) => {
17634
17823
  onOpenChange(!open);
17635
17824
  onClick?.(e);
@@ -17639,7 +17828,7 @@ var TooltipTrigger = React32.forwardRef(({ onClick, ...props }, ref) => {
17639
17828
  return /* @__PURE__ */ jsx52(TooltipPrimitive.Trigger, { ref, onClick: handleClick, ...props });
17640
17829
  });
17641
17830
  TooltipTrigger.displayName = TooltipPrimitive.Trigger.displayName;
17642
- var TooltipContent = React32.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
17831
+ var TooltipContent = React33.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
17643
17832
  const { themeClass, colors: colors2 } = useTheme();
17644
17833
  return /* @__PURE__ */ jsx52(TooltipPrimitive.Portal, { children: /* @__PURE__ */ jsx52(
17645
17834
  TooltipPrimitive.Content,
@@ -17665,7 +17854,7 @@ import {
17665
17854
  } from "@unifold/core";
17666
17855
 
17667
17856
  // src/hooks/use-hypercore-activation.ts
17668
- import { useQuery as useQuery14 } from "@tanstack/react-query";
17857
+ import { useQuery as useQuery15 } from "@tanstack/react-query";
17669
17858
  import { checkHypercoreActivation } from "@unifold/core";
17670
17859
 
17671
17860
  // src/lib/constants.ts
@@ -17684,7 +17873,7 @@ function useHypercoreActivation(params) {
17684
17873
  const recipient = recipientAddress?.trim() ?? "";
17685
17874
  const source = sourceAddress?.trim() ?? "";
17686
17875
  const hasAddresses = !!recipient && !!source;
17687
- const { data, isLoading } = useQuery14({
17876
+ const { data, isLoading } = useQuery15({
17688
17877
  queryKey: ["unifold", "hypercoreActivation", source, recipient, publishableKey],
17689
17878
  queryFn: () => checkHypercoreActivation(
17690
17879
  {
@@ -17770,6 +17959,7 @@ function TransferCryptoSingleInput({
17770
17959
  onDepositError,
17771
17960
  wallets: externalWallets,
17772
17961
  onSourceTokenChange,
17962
+ prefilledAmountUsd,
17773
17963
  checkoutQuote,
17774
17964
  isCheckoutQuoteLoading = false,
17775
17965
  persistCheckingIndicator = false,
@@ -17817,7 +18007,7 @@ function TransferCryptoSingleInput({
17817
18007
  const wallets = externalWallets?.length ? externalWallets : depositAddressResponse?.data ?? [];
17818
18008
  const loading = externalWallets?.length ? false : walletsLoading;
17819
18009
  const error = walletsError?.message ?? null;
17820
- const allAvailableChains = useMemo10(() => {
18010
+ const allAvailableChains = useMemo11(() => {
17821
18011
  const chainsMap = /* @__PURE__ */ new Map();
17822
18012
  supportedTokens.forEach((t13) => {
17823
18013
  t13.chains.forEach((c) => {
@@ -17913,6 +18103,22 @@ function TransferCryptoSingleInput({
17913
18103
  const maxSlippage = currentChainFromBackend?.max_slippage_percent ?? 0.25;
17914
18104
  const processingTime = currentChainFromBackend?.estimated_processing_time ?? null;
17915
18105
  const minDepositUsd = currentChainFromBackend?.minimum_deposit_amount_usd ?? 3;
18106
+ const parsedPrefilledUsd = useMemo11(() => {
18107
+ const value = parseFloat(prefilledAmountUsd ?? "");
18108
+ return Number.isFinite(value) && value > 0 ? value : null;
18109
+ }, [prefilledAmountUsd]);
18110
+ const effectivePrefilledUsd = useMemo11(() => {
18111
+ if (parsedPrefilledUsd === null) return null;
18112
+ return Math.max(parsedPrefilledUsd, minDepositUsd);
18113
+ }, [parsedPrefilledUsd, minDepositUsd]);
18114
+ const prefillDisplay = useMemo11(() => {
18115
+ if (effectivePrefilledUsd === null) return null;
18116
+ const usdLabel = `$${effectivePrefilledUsd.toFixed(2)}`;
18117
+ if (selectedToken?.is_stablecoin) {
18118
+ return `${effectivePrefilledUsd.toFixed(2)} ${selectedToken.symbol} (${usdLabel})`;
18119
+ }
18120
+ return `${usdLabel} USD`;
18121
+ }, [effectivePrefilledUsd, selectedToken]);
17916
18122
  return /* @__PURE__ */ jsx54(TooltipProvider, { delayDuration: 0, skipDelayDuration: 0, children: /* @__PURE__ */ jsxs49(
17917
18123
  "div",
17918
18124
  {
@@ -18039,7 +18245,7 @@ function TransferCryptoSingleInput({
18039
18245
  /* @__PURE__ */ jsx54("span", { children: "Retrying automatically every 5 seconds..." })
18040
18246
  ] })
18041
18247
  ] }),
18042
- (checkoutQuote || isCheckoutQuoteLoading) && /* @__PURE__ */ jsxs49(
18248
+ (checkoutQuote || isCheckoutQuoteLoading || prefillDisplay) && /* @__PURE__ */ jsxs49(
18043
18249
  "div",
18044
18250
  {
18045
18251
  className: "uf-rounded-xl uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
@@ -18083,6 +18289,13 @@ function TransferCryptoSingleInput({
18083
18289
  )
18084
18290
  ]
18085
18291
  }
18292
+ ) : prefillDisplay ? /* @__PURE__ */ jsx54(
18293
+ "span",
18294
+ {
18295
+ className: "uf-text-sm uf-font-semibold",
18296
+ style: { color: components.card.titleColor, fontFamily: fonts.semibold },
18297
+ children: prefillDisplay
18298
+ }
18086
18299
  ) : /* @__PURE__ */ jsx54(
18087
18300
  "div",
18088
18301
  {
@@ -18412,7 +18625,7 @@ function TransferCryptoSingleInput({
18412
18625
  }
18413
18626
 
18414
18627
  // src/components/deposits/TransferCryptoDoubleInput.tsx
18415
- import { useState as useState37, useEffect as useEffect31, useMemo as useMemo11 } from "react";
18628
+ import { useState as useState37, useEffect as useEffect31, useMemo as useMemo12 } from "react";
18416
18629
  import {
18417
18630
  ChevronDown as ChevronDown7,
18418
18631
  ChevronUp as ChevronUp5,
@@ -18427,14 +18640,14 @@ import {
18427
18640
  } from "lucide-react";
18428
18641
 
18429
18642
  // src/components/shared/select.tsx
18430
- import * as React33 from "react";
18643
+ import * as React34 from "react";
18431
18644
  import * as SelectPrimitive from "@radix-ui/react-select";
18432
18645
  import { Check as Check5, ChevronDown as ChevronDown6, ChevronUp as ChevronUp4 } from "lucide-react";
18433
18646
  import { jsx as jsx55, jsxs as jsxs50 } from "react/jsx-runtime";
18434
18647
  var Select = SelectPrimitive.Root;
18435
18648
  var SelectGroup = SelectPrimitive.Group;
18436
18649
  var SelectValue = SelectPrimitive.Value;
18437
- var SelectTrigger = React33.forwardRef(({ className, style, children, ...props }, ref) => {
18650
+ var SelectTrigger = React34.forwardRef(({ className, style, children, ...props }, ref) => {
18438
18651
  const { components } = useTheme();
18439
18652
  return /* @__PURE__ */ jsxs50(
18440
18653
  SelectPrimitive.Trigger,
@@ -18458,7 +18671,7 @@ var SelectTrigger = React33.forwardRef(({ className, style, children, ...props }
18458
18671
  );
18459
18672
  });
18460
18673
  SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
18461
- var SelectScrollUpButton = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx55(
18674
+ var SelectScrollUpButton = React34.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx55(
18462
18675
  SelectPrimitive.ScrollUpButton,
18463
18676
  {
18464
18677
  ref,
@@ -18468,7 +18681,7 @@ var SelectScrollUpButton = React33.forwardRef(({ className, ...props }, ref) =>
18468
18681
  }
18469
18682
  ));
18470
18683
  SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
18471
- var SelectScrollDownButton = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx55(
18684
+ var SelectScrollDownButton = React34.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx55(
18472
18685
  SelectPrimitive.ScrollDownButton,
18473
18686
  {
18474
18687
  ref,
@@ -18478,7 +18691,7 @@ var SelectScrollDownButton = React33.forwardRef(({ className, ...props }, ref) =
18478
18691
  }
18479
18692
  ));
18480
18693
  SelectScrollDownButton.displayName = SelectPrimitive.ScrollDownButton.displayName;
18481
- var SelectContent = React33.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
18694
+ var SelectContent = React34.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
18482
18695
  const { themeClass, colors: colors2, components } = useTheme();
18483
18696
  return /* @__PURE__ */ jsx55(SelectPrimitive.Portal, { children: /* @__PURE__ */ jsxs50(
18484
18697
  SelectPrimitive.Content,
@@ -18516,7 +18729,7 @@ var SelectContent = React33.forwardRef(({ className, style, children, position =
18516
18729
  ) });
18517
18730
  });
18518
18731
  SelectContent.displayName = SelectPrimitive.Content.displayName;
18519
- var SelectLabel = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx55(
18732
+ var SelectLabel = React34.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx55(
18520
18733
  SelectPrimitive.Label,
18521
18734
  {
18522
18735
  ref,
@@ -18525,7 +18738,7 @@ var SelectLabel = React33.forwardRef(({ className, ...props }, ref) => /* @__PUR
18525
18738
  }
18526
18739
  ));
18527
18740
  SelectLabel.displayName = SelectPrimitive.Label.displayName;
18528
- var SelectItem = React33.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs50(
18741
+ var SelectItem = React34.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs50(
18529
18742
  SelectPrimitive.Item,
18530
18743
  {
18531
18744
  ref,
@@ -18541,7 +18754,7 @@ var SelectItem = React33.forwardRef(({ className, children, ...props }, ref) =>
18541
18754
  }
18542
18755
  ));
18543
18756
  SelectItem.displayName = SelectPrimitive.Item.displayName;
18544
- var SelectSeparator = React33.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx55(
18757
+ var SelectSeparator = React34.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx55(
18545
18758
  SelectPrimitive.Separator,
18546
18759
  {
18547
18760
  ref,
@@ -18575,6 +18788,7 @@ function TransferCryptoDoubleInput({
18575
18788
  defaultSourceChainId,
18576
18789
  defaultSourceTokenAddress,
18577
18790
  defaultSourceSymbol,
18791
+ prefilledAmountUsd,
18578
18792
  depositConfirmationMode = "auto_ui",
18579
18793
  onExecutionsChange,
18580
18794
  onDepositSuccess,
@@ -18621,7 +18835,7 @@ function TransferCryptoDoubleInput({
18621
18835
  const wallets = externalWallets?.length ? externalWallets : depositAddressResponse?.data ?? [];
18622
18836
  const loading = externalWallets?.length ? false : walletsLoading;
18623
18837
  const error = walletsError?.message ?? null;
18624
- const allAvailableChains = useMemo11(() => {
18838
+ const allAvailableChains = useMemo12(() => {
18625
18839
  const chainsMap = /* @__PURE__ */ new Map();
18626
18840
  supportedTokens.forEach((t13) => {
18627
18841
  t13.chains.forEach((c) => {
@@ -18699,6 +18913,22 @@ function TransferCryptoDoubleInput({
18699
18913
  const maxSlippage = currentChainFromBackend?.max_slippage_percent ?? 0.25;
18700
18914
  const processingTime = currentChainFromBackend?.estimated_processing_time ?? null;
18701
18915
  const minDepositUsd = currentChainFromBackend?.minimum_deposit_amount_usd ?? 3;
18916
+ const parsedPrefilledUsd = useMemo12(() => {
18917
+ const value = parseFloat(prefilledAmountUsd ?? "");
18918
+ return Number.isFinite(value) && value > 0 ? value : null;
18919
+ }, [prefilledAmountUsd]);
18920
+ const effectivePrefilledUsd = useMemo12(() => {
18921
+ if (parsedPrefilledUsd === null) return null;
18922
+ return Math.max(parsedPrefilledUsd, minDepositUsd);
18923
+ }, [parsedPrefilledUsd, minDepositUsd]);
18924
+ const prefillDisplay = useMemo12(() => {
18925
+ if (effectivePrefilledUsd === null) return null;
18926
+ const usdLabel = `$${effectivePrefilledUsd.toFixed(2)}`;
18927
+ if (selectedToken?.is_stablecoin) {
18928
+ return `${effectivePrefilledUsd.toFixed(2)} ${selectedToken.symbol} (${usdLabel})`;
18929
+ }
18930
+ return `${usdLabel} USD`;
18931
+ }, [effectivePrefilledUsd, selectedToken]);
18702
18932
  const renderTokenItem = (tokenData) => {
18703
18933
  return /* @__PURE__ */ jsxs51("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
18704
18934
  /* @__PURE__ */ jsx56(
@@ -18879,6 +19109,35 @@ function TransferCryptoDoubleInput({
18879
19109
  /* @__PURE__ */ jsx56("span", { children: "Retrying automatically every 5 seconds..." })
18880
19110
  ] })
18881
19111
  ] }),
19112
+ prefillDisplay && /* @__PURE__ */ jsxs51(
19113
+ "div",
19114
+ {
19115
+ className: "uf-rounded-xl uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
19116
+ style: {
19117
+ backgroundColor: components.card.backgroundColor,
19118
+ border: `${components.card.borderWidth}px solid ${components.card.borderColor}`,
19119
+ borderRadius: components.card.borderRadius
19120
+ },
19121
+ children: [
19122
+ /* @__PURE__ */ jsx56(
19123
+ "span",
19124
+ {
19125
+ className: "uf-text-xs",
19126
+ style: { color: components.card.subtitleColor, fontFamily: fonts.regular },
19127
+ children: "You send"
19128
+ }
19129
+ ),
19130
+ /* @__PURE__ */ jsx56(
19131
+ "span",
19132
+ {
19133
+ className: "uf-text-sm uf-font-semibold",
19134
+ style: { color: components.card.titleColor, fontFamily: fonts.semibold },
19135
+ children: prefillDisplay
19136
+ }
19137
+ )
19138
+ ]
19139
+ }
19140
+ ),
18882
19141
  /* @__PURE__ */ jsxs51("div", { className: "uf-flex uf-flex-col uf-items-center uf-pt-2", children: [
18883
19142
  /* @__PURE__ */ jsx56(
18884
19143
  "div",
@@ -19161,7 +19420,7 @@ function TransferCryptoDoubleInput({
19161
19420
  }
19162
19421
 
19163
19422
  // src/components/deposits/WalletConnect.tsx
19164
- import * as React34 from "react";
19423
+ import * as React35 from "react";
19165
19424
  import { ExternalLink as ExternalLink4, Loader2 as Loader210 } from "lucide-react";
19166
19425
  import {
19167
19426
  getAddressBalances as getAddressBalances2,
@@ -19213,7 +19472,7 @@ async function sendHypercoreEvmTransfer(params) {
19213
19472
  }
19214
19473
 
19215
19474
  // src/hooks/use-deposit-quote.ts
19216
- import { useQuery as useQuery15 } from "@tanstack/react-query";
19475
+ import { useQuery as useQuery16 } from "@tanstack/react-query";
19217
19476
  import { getDepositQuote } from "@unifold/core";
19218
19477
  function useDepositQuote(params) {
19219
19478
  const {
@@ -19240,7 +19499,7 @@ function useDepositQuote(params) {
19240
19499
  ...adjustForSlippage ? { adjust_for_slippage: true } : {},
19241
19500
  ...stablecoinParity ? { stablecoin_parity: true } : {}
19242
19501
  };
19243
- return useQuery15({
19502
+ return useQuery16({
19244
19503
  queryKey: [
19245
19504
  "unifold",
19246
19505
  "depositQuote",
@@ -19268,13 +19527,13 @@ function useDepositQuote(params) {
19268
19527
  }
19269
19528
 
19270
19529
  // src/hooks/use-external-wallets.ts
19271
- import { useQuery as useQuery16 } from "@tanstack/react-query";
19530
+ import { useQuery as useQuery17 } from "@tanstack/react-query";
19272
19531
  import { getExternalWallets } from "@unifold/core";
19273
19532
  function useExternalWallets({
19274
19533
  publishableKey,
19275
19534
  enabled = true
19276
19535
  }) {
19277
- const { data: wallets = [], isLoading } = useQuery16({
19536
+ const { data: wallets = [], isLoading } = useQuery17({
19278
19537
  queryKey: ["unifold", "external-wallets", publishableKey],
19279
19538
  queryFn: () => getExternalWallets(publishableKey).then((res) => res.data),
19280
19539
  enabled: enabled && !!publishableKey,
@@ -20521,7 +20780,7 @@ function WalletConnect({
20521
20780
  amountQuickSelect = "percentage",
20522
20781
  onWalletDisconnect,
20523
20782
  onWalletConnected,
20524
- prefillAmountUsd,
20783
+ prefilledAmountUsd,
20525
20784
  checkoutAmountUsd,
20526
20785
  checkoutReceivedUsd,
20527
20786
  onNewDeposit,
@@ -20543,28 +20802,28 @@ function WalletConnect({
20543
20802
  onExecutionsChange
20544
20803
  }) {
20545
20804
  const { colors: colors2, fonts, components, mode } = useTheme();
20546
- const walletProvidedAtMount = React34.useRef(!!initialWalletInfo && !!initialDepositWallet);
20547
- const [activeWalletInfo, setActiveWalletInfo] = React34.useState(
20805
+ const walletProvidedAtMount = React35.useRef(!!initialWalletInfo && !!initialDepositWallet);
20806
+ const [activeWalletInfo, setActiveWalletInfo] = React35.useState(
20548
20807
  initialWalletInfo ?? null
20549
20808
  );
20550
- const [activeDepositWallet, setActiveDepositWallet] = React34.useState(
20809
+ const [activeDepositWallet, setActiveDepositWallet] = React35.useState(
20551
20810
  initialDepositWallet ?? null
20552
20811
  );
20553
20812
  const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
20554
- const [view, setView] = React34.useState(initialView);
20555
- const [isTransitioning, setIsTransitioning] = React34.useState(false);
20556
- const viewRef = React34.useRef(initialView);
20813
+ const [view, setView] = React35.useState(initialView);
20814
+ const [isTransitioning, setIsTransitioning] = React35.useState(false);
20815
+ const viewRef = React35.useRef(initialView);
20557
20816
  const standalone = !canGoBack && !walletProvidedAtMount.current;
20558
20817
  const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({
20559
20818
  enabled: standalone
20560
20819
  });
20561
- const [autoResolved, setAutoResolved] = React34.useState(false);
20562
- const [selectedWalletDef, setSelectedWalletDef] = React34.useState(null);
20563
- const [connectingNetwork, setConnectingNetwork] = React34.useState(null);
20564
- const [walletError, setWalletError] = React34.useState(null);
20565
- const [isWalletConnecting, setIsWalletConnecting] = React34.useState(false);
20566
- const [eip6963ProviderCount, setEip6963ProviderCount] = React34.useState(0);
20567
- React34.useEffect(() => {
20820
+ const [autoResolved, setAutoResolved] = React35.useState(false);
20821
+ const [selectedWalletDef, setSelectedWalletDef] = React35.useState(null);
20822
+ const [connectingNetwork, setConnectingNetwork] = React35.useState(null);
20823
+ const [walletError, setWalletError] = React35.useState(null);
20824
+ const [isWalletConnecting, setIsWalletConnecting] = React35.useState(false);
20825
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React35.useState(0);
20826
+ React35.useEffect(() => {
20568
20827
  const store = getEip6963Store();
20569
20828
  if (!store) return;
20570
20829
  setEip6963ProviderCount(store.getProviders().length);
@@ -20573,7 +20832,7 @@ function WalletConnect({
20573
20832
  });
20574
20833
  }, []);
20575
20834
  const { wallets: backendWallets } = useExternalWallets({ publishableKey });
20576
- const walletDefinitions = React34.useMemo(
20835
+ const walletDefinitions = React35.useMemo(
20577
20836
  () => backendWallets.length > 0 ? backendWallets.map((w) => ({
20578
20837
  id: w.id,
20579
20838
  name: w.name,
@@ -20584,32 +20843,32 @@ function WalletConnect({
20584
20843
  })) : FALLBACK_WALLET_DEFINITIONS,
20585
20844
  [backendWallets]
20586
20845
  );
20587
- const [recentWalletId, setRecentWalletIdState] = React34.useState(getLastOpenedWallet);
20588
- React34.useEffect(() => {
20846
+ const [recentWalletId, setRecentWalletIdState] = React35.useState(getLastOpenedWallet);
20847
+ React35.useEffect(() => {
20589
20848
  if (view === "select_wallet") {
20590
20849
  setRecentWalletIdState(getLastOpenedWallet());
20591
20850
  }
20592
20851
  }, [view]);
20593
- const availableWallets = React34.useMemo(
20852
+ const availableWallets = React35.useMemo(
20594
20853
  () => detectAvailableWallets(walletDefinitions, recentWalletId),
20595
20854
  [walletDefinitions, eip6963ProviderCount, recentWalletId]
20596
20855
  );
20597
- const [isMobile, setIsMobile] = React34.useState(false);
20598
- React34.useEffect(() => {
20856
+ const [isMobile, setIsMobile] = React35.useState(false);
20857
+ React35.useEffect(() => {
20599
20858
  setIsMobile(isMobileDevice());
20600
20859
  }, []);
20601
- const mobileDepositAddresses = React34.useMemo(
20860
+ const mobileDepositAddresses = React35.useMemo(
20602
20861
  () => (depositWallets ?? []).map((w) => ({ chain_type: w.chain_type, address: w.address })),
20603
20862
  [depositWallets]
20604
20863
  );
20605
- const mobileDepositWalletIds = React34.useMemo(
20864
+ const mobileDepositWalletIds = React35.useMemo(
20606
20865
  () => (depositWallets ?? []).filter((w) => w.chain_type === "ethereum" || w.chain_type === "solana").map((w) => w.id),
20607
20866
  [depositWallets]
20608
20867
  );
20609
- const [mobileRedirect, setMobileRedirect] = React34.useState(null);
20610
- const [pendingMobileWallet, setPendingMobileWallet] = React34.useState(null);
20611
- const [awaitingMobileDeposit, setAwaitingMobileDeposit] = React34.useState(false);
20612
- React34.useEffect(() => {
20868
+ const [mobileRedirect, setMobileRedirect] = React35.useState(null);
20869
+ const [pendingMobileWallet, setPendingMobileWallet] = React35.useState(null);
20870
+ const [awaitingMobileDeposit, setAwaitingMobileDeposit] = React35.useState(false);
20871
+ React35.useEffect(() => {
20613
20872
  if (!standalone || autoResolved || detectingWallet) return;
20614
20873
  if (!detectedWallet) {
20615
20874
  setAutoResolved(true);
@@ -20635,32 +20894,36 @@ function WalletConnect({
20635
20894
  depositWallets,
20636
20895
  depositWalletsLoading
20637
20896
  ]);
20638
- React34.useEffect(() => {
20897
+ React35.useEffect(() => {
20639
20898
  if (!standalone || autoResolved) return;
20640
20899
  const t13 = setTimeout(() => setAutoResolved(true), 5e3);
20641
20900
  return () => clearTimeout(t13);
20642
20901
  }, [standalone, autoResolved]);
20643
- const [balances, setBalances] = React34.useState([]);
20644
- const [isLoading, setIsLoading] = React34.useState(false);
20645
- const [selectedBalance, setSelectedBalance] = React34.useState(null);
20646
- const [totalBalanceUsd, setTotalBalanceUsd] = React34.useState(null);
20647
- const [error, setError] = React34.useState(null);
20648
- const [isDisconnectingWallet, setIsDisconnectingWallet] = React34.useState(false);
20649
- const [amountUsd, setAmountUsd] = React34.useState(prefillAmountUsd ?? "");
20650
- const [isConfirming, setIsConfirming] = React34.useState(false);
20651
- const [hasSignedTransaction, setHasSignedTransaction] = React34.useState(false);
20652
- const [tokenChainDetails, setTokenChainDetails] = React34.useState(null);
20653
- const [loadingTokenDetails, setLoadingTokenDetails] = React34.useState(false);
20654
- const [showTransactionDetails, setShowTransactionDetails] = React34.useState(false);
20655
- const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React34.useState(null);
20902
+ const [balances, setBalances] = React35.useState([]);
20903
+ const [isLoading, setIsLoading] = React35.useState(false);
20904
+ const [selectedBalance, setSelectedBalance] = React35.useState(null);
20905
+ const [totalBalanceUsd, setTotalBalanceUsd] = React35.useState(null);
20906
+ const [error, setError] = React35.useState(null);
20907
+ const [isDisconnectingWallet, setIsDisconnectingWallet] = React35.useState(false);
20908
+ const [amountUsd, setAmountUsd] = React35.useState(prefilledAmountUsd ?? "");
20909
+ const [isConfirming, setIsConfirming] = React35.useState(false);
20910
+ const [hasSignedTransaction, setHasSignedTransaction] = React35.useState(false);
20911
+ const [tokenChainDetails, setTokenChainDetails] = React35.useState(null);
20912
+ const [loadingTokenDetails, setLoadingTokenDetails] = React35.useState(false);
20913
+ const [showTransactionDetails, setShowTransactionDetails] = React35.useState(false);
20914
+ const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React35.useState(null);
20656
20915
  const walletInfo = activeWalletInfo;
20657
20916
  const depositWallet = activeDepositWallet;
20658
20917
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
20918
+ React35.useEffect(() => {
20919
+ const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
20920
+ setAmountUsd(cleanedPrefilled);
20921
+ }, [prefilledAmountUsd]);
20659
20922
  const chainType = activeDepositWallet?.chain_type ?? "ethereum";
20660
20923
  const recipientAddress = activeDepositWallet?.address ?? "";
20661
20924
  const isCheckoutMode = !!checkoutAmountUsd;
20662
20925
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" || chainType === "cardano" || chainType === "n1" ? "ethereum" : chainType;
20663
- const transitionTo = React34.useCallback((nextView) => {
20926
+ const transitionTo = React35.useCallback((nextView) => {
20664
20927
  if (nextView === viewRef.current) return;
20665
20928
  setIsTransitioning(true);
20666
20929
  setTimeout(() => {
@@ -20725,7 +20988,7 @@ function WalletConnect({
20725
20988
  if (!selectedWalletDef) return;
20726
20989
  handleConnectWallet(selectedWalletDef, network);
20727
20990
  };
20728
- React34.useEffect(() => {
20991
+ React35.useEffect(() => {
20729
20992
  if (!pendingMobileWallet) return;
20730
20993
  if (mobileDepositAddresses.length > 0) {
20731
20994
  const wallet = pendingMobileWallet;
@@ -20889,7 +21152,7 @@ function WalletConnect({
20889
21152
  publishableKey,
20890
21153
  enabled: !!activeWalletInfo && !!recipientAddress
20891
21154
  });
20892
- const effectiveDestinationAmount = React34.useMemo(() => {
21155
+ const effectiveDestinationAmount = React35.useMemo(() => {
20893
21156
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
20894
21157
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
20895
21158
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -20917,7 +21180,7 @@ function WalletConnect({
20917
21180
  stablecoinParity,
20918
21181
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
20919
21182
  });
20920
- const activeCheckoutQuote = React34.useMemo(() => {
21183
+ const activeCheckoutQuote = React35.useMemo(() => {
20921
21184
  if (!isCheckoutMode) return null;
20922
21185
  if (walletCheckoutQuote)
20923
21186
  return {
@@ -20947,10 +21210,10 @@ function WalletConnect({
20947
21210
  onDepositSuccess,
20948
21211
  onDepositError
20949
21212
  });
20950
- React34.useEffect(() => {
21213
+ React35.useEffect(() => {
20951
21214
  onExecutionsChange?.(depositExecutions);
20952
21215
  }, [depositExecutions, onExecutionsChange]);
20953
- const latestDepositExecution = React34.useMemo(() => {
21216
+ const latestDepositExecution = React35.useMemo(() => {
20954
21217
  if (depositExecutions.length === 0) return null;
20955
21218
  return [...depositExecutions].sort((a, b) => {
20956
21219
  const ta = a.created_at ? new Date(a.created_at).getTime() : 0;
@@ -20958,21 +21221,21 @@ function WalletConnect({
20958
21221
  return tb - ta;
20959
21222
  })[0];
20960
21223
  }, [depositExecutions]);
20961
- React34.useEffect(() => {
21224
+ React35.useEffect(() => {
20962
21225
  if (awaitingMobileDeposit && latestDepositExecution && (viewRef.current === "mobile_redirect" || viewRef.current === "connecting")) {
20963
21226
  transitionTo("mobile_deposit_status");
20964
21227
  }
20965
21228
  }, [awaitingMobileDeposit, latestDepositExecution, transitionTo]);
20966
- React34.useEffect(() => {
20967
- if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
21229
+ React35.useEffect(() => {
21230
+ if (!isCheckoutMode || !tokenChainDetails || view !== "enter_amount") return;
20968
21231
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
20969
21232
  const currentAmount = parseFloat(amountUsd) || 0;
20970
21233
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
20971
- }, [tokenChainDetails, view, prefillAmountUsd]);
20972
- React34.useEffect(() => {
21234
+ }, [isCheckoutMode, tokenChainDetails, view, amountUsd]);
21235
+ React35.useEffect(() => {
20973
21236
  if (view === "review") setShowTransactionDetails(false);
20974
21237
  }, [view]);
20975
- React34.useEffect(() => {
21238
+ React35.useEffect(() => {
20976
21239
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet)
20977
21240
  return;
20978
21241
  let cancelled = false;
@@ -21009,7 +21272,7 @@ function WalletConnect({
21009
21272
  cancelled = true;
21010
21273
  };
21011
21274
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
21012
- React34.useEffect(() => {
21275
+ React35.useEffect(() => {
21013
21276
  if (!activeWalletInfo || !activeDepositWallet) return;
21014
21277
  let cancelled = false;
21015
21278
  setIsLoading(true);
@@ -21074,21 +21337,21 @@ function WalletConnect({
21074
21337
  defaultSourceTokenAddress,
21075
21338
  defaultSourceSymbol
21076
21339
  ]);
21077
- const usdToTokenRate = React34.useMemo(() => {
21340
+ const usdToTokenRate = React35.useMemo(() => {
21078
21341
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
21079
21342
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
21080
21343
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
21081
21344
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
21082
21345
  return balanceAmount / balanceUsd;
21083
21346
  }, [selectedBalance, selectedToken]);
21084
- const tokenAmount = React34.useMemo(() => {
21347
+ const tokenAmount = React35.useMemo(() => {
21085
21348
  if (isCheckoutMode && activeCheckoutQuote && selectedToken)
21086
21349
  return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
21087
21350
  const usdNum = parseFloat(amountUsd) || 0;
21088
21351
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
21089
21352
  return usdNum * usdToTokenRate;
21090
21353
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
21091
- React34.useEffect(() => {
21354
+ React35.useEffect(() => {
21092
21355
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount")
21093
21356
  setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
21094
21357
  }, [isCheckoutMode, activeCheckoutQuote, view]);
@@ -21097,7 +21360,7 @@ function WalletConnect({
21097
21360
  const inputUsdNum = parseFloat(amountUsd) || 0;
21098
21361
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
21099
21362
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
21100
- const formattedTokenAmount = React34.useMemo(() => {
21363
+ const formattedTokenAmount = React35.useMemo(() => {
21101
21364
  if (tokenAmount === 0 || !selectedToken) return null;
21102
21365
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
21103
21366
  }, [tokenAmount, selectedToken]);
@@ -21130,7 +21393,7 @@ function WalletConnect({
21130
21393
  break;
21131
21394
  case "enter_amount":
21132
21395
  transitionTo("select_token");
21133
- setAmountUsd(prefillAmountUsd ?? "");
21396
+ setAmountUsd(prefilledAmountUsd ?? "");
21134
21397
  setTokenChainDetails(null);
21135
21398
  break;
21136
21399
  case "review":
@@ -21162,7 +21425,7 @@ function WalletConnect({
21162
21425
  setSelectedBalance(null);
21163
21426
  setBalances([]);
21164
21427
  setTotalBalanceUsd(null);
21165
- setAmountUsd(prefillAmountUsd ?? "");
21428
+ setAmountUsd(prefilledAmountUsd ?? "");
21166
21429
  setError(null);
21167
21430
  };
21168
21431
  if (standalone) {
@@ -21889,6 +22152,15 @@ function SkeletonButton({ variant = "default" }) {
21889
22152
  ] });
21890
22153
  }
21891
22154
  var t8 = i18n.depositModal;
22155
+ function normalizePrefilledUsdAmount(value) {
22156
+ if (!value) return void 0;
22157
+ const cleaned = value.replace(/[^0-9.]/g, "");
22158
+ if (!cleaned) return void 0;
22159
+ const normalizedNumeric = cleaned.replace(/(\..*)\./g, "$1");
22160
+ const parsed = parseFloat(normalizedNumeric);
22161
+ if (!Number.isFinite(parsed) || parsed <= 0) return void 0;
22162
+ return parseFloat(parsed.toFixed(2)).toString();
22163
+ }
21892
22164
  function depositTabForScreen(screen) {
21893
22165
  return screen === "card" || screen === "cashapp" || screen === "bank_transfer" || screen === "stripe_link" || screen === "apple_pay" ? "cash" : "crypto";
21894
22166
  }
@@ -21908,6 +22180,7 @@ function DepositModal({
21908
22180
  defaultSourceChainId,
21909
22181
  defaultSourceTokenAddress,
21910
22182
  defaultSourceSymbol,
22183
+ prefilledAmountUsd,
21911
22184
  hideDepositTracker,
21912
22185
  showBalanceHeader = false,
21913
22186
  transferInputVariant = "double_input",
@@ -21943,7 +22216,11 @@ function DepositModal({
21943
22216
  depositTrackerSubTitle = t8.depositTracker.subtitle
21944
22217
  }) {
21945
22218
  const { colors: colors2, fonts, components } = useTheme();
21946
- const onDepositSuccessFor = useCallback8(
22219
+ const normalizedPrefilledAmountUsd = useMemo14(
22220
+ () => normalizePrefilledUsdAmount(prefilledAmountUsd),
22221
+ [prefilledAmountUsd]
22222
+ );
22223
+ const onDepositSuccessFor = useCallback10(
21947
22224
  (method) => onDepositSuccess || onEvent ? (data) => {
21948
22225
  const payload = { ...data, method };
21949
22226
  onDepositSuccess?.(payload);
@@ -21956,11 +22233,11 @@ function DepositModal({
21956
22233
  } : void 0,
21957
22234
  [onDepositSuccess, onEvent]
21958
22235
  );
21959
- const onDepositErrorFor = useCallback8(
22236
+ const onDepositErrorFor = useCallback10(
21960
22237
  (method) => onDepositError ? (error) => onDepositError({ ...error, method }) : void 0,
21961
22238
  [onDepositError]
21962
22239
  );
21963
- const effectiveInitialScreen = useMemo13(() => {
22240
+ const effectiveInitialScreen = useMemo14(() => {
21964
22241
  const s = initialScreen ?? "main";
21965
22242
  if (s === "tracker" && hideDepositTracker === true) return "main";
21966
22243
  if (s === "cashapp" && enableCashApp === false) return "main";
@@ -21986,7 +22263,7 @@ function DepositModal({
21986
22263
  enableStripeLink
21987
22264
  ]);
21988
22265
  const [containerEl, setContainerEl] = useState40(null);
21989
- const containerCallbackRef = useCallback8((el) => {
22266
+ const containerCallbackRef = useCallback10((el) => {
21990
22267
  setContainerEl(el);
21991
22268
  }, []);
21992
22269
  const [view, setView] = useState40(effectiveInitialScreen);
@@ -21995,7 +22272,7 @@ function DepositModal({
21995
22272
  const [depositTab, setDepositTab] = useState40(
21996
22273
  () => depositTabForScreen(effectiveInitialScreen)
21997
22274
  );
21998
- const resetViewTimeoutRef = useRef12(null);
22275
+ const resetViewTimeoutRef = useRef13(null);
21999
22276
  const [cardView, setCardView] = useState40("amount");
22000
22277
  const [exchangeView, setExchangeView] = useState40("providers");
22001
22278
  const [browserWalletModalOpen, setBrowserWalletModalOpen] = useState40(false);
@@ -22339,7 +22616,7 @@ function DepositModal({
22339
22616
  );
22340
22617
  const [cashAppView, setCashAppView] = useState40("amount");
22341
22618
  const [stripeLinkStep, setStripeLinkStep] = useState40("amount");
22342
- const stripeLinkBackRef = useRef12(null);
22619
+ const stripeLinkBackRef = useRef13(null);
22343
22620
  useEffect34(() => {
22344
22621
  if (view === "stripe_link" && !showStripeLink && effectiveInitialScreen === "main") {
22345
22622
  setView("main");
@@ -22348,7 +22625,7 @@ function DepositModal({
22348
22625
  }, [view, showStripeLink, effectiveInitialScreen]);
22349
22626
  const [cashAppAmount, setCashAppAmount] = useState40("");
22350
22627
  const [applePayView, setApplePayView] = useState40("email_input");
22351
- const applePayHandleRef = useRef12(null);
22628
+ const applePayHandleRef = useRef13(null);
22352
22629
  const applePayHeaderTitle = (() => {
22353
22630
  switch (applePayView) {
22354
22631
  case "email_input":
@@ -22808,6 +23085,7 @@ function DepositModal({
22808
23085
  defaultSourceChainId,
22809
23086
  defaultSourceTokenAddress,
22810
23087
  defaultSourceSymbol,
23088
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
22811
23089
  depositConfirmationMode,
22812
23090
  onExecutionsChange: setDepositExecutions,
22813
23091
  onDepositSuccess: onDepositSuccessFor("transfer"),
@@ -22827,6 +23105,7 @@ function DepositModal({
22827
23105
  defaultSourceChainId,
22828
23106
  defaultSourceTokenAddress,
22829
23107
  defaultSourceSymbol,
23108
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
22830
23109
  depositConfirmationMode,
22831
23110
  onExecutionsChange: setDepositExecutions,
22832
23111
  onDepositSuccess: onDepositSuccessFor("transfer"),
@@ -22911,7 +23190,8 @@ function DepositModal({
22911
23190
  wallets,
22912
23191
  assetCdnUrl: projectConfig?.asset_cdn_url,
22913
23192
  hideDepositFlowInfo,
22914
- hideDisplayDescription
23193
+ hideDisplayDescription,
23194
+ prefilledAmountUsd: normalizedPrefilledAmountUsd
22915
23195
  }
22916
23196
  ),
22917
23197
  depositPoweredByFooter
@@ -22976,7 +23256,8 @@ function DepositModal({
22976
23256
  defaultSourceChainType,
22977
23257
  defaultSourceChainId,
22978
23258
  defaultSourceTokenAddress,
22979
- defaultSourceSymbol
23259
+ defaultSourceSymbol,
23260
+ prefilledAmountUsd: normalizedPrefilledAmountUsd
22980
23261
  }
22981
23262
  ),
22982
23263
  depositPoweredByFooter
@@ -23008,6 +23289,7 @@ function DepositModal({
23008
23289
  onDepositSuccess: onDepositSuccessFor("wallet_connect"),
23009
23290
  onDepositError: onDepositErrorFor("wallet_connect"),
23010
23291
  amountQuickSelect: browserWalletAmountQuickSelect,
23292
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
23011
23293
  onWalletDisconnect: handleWalletDisconnect,
23012
23294
  onWalletConnected: (info, dw) => {
23013
23295
  setBrowserWalletInfo({ ...info, depositWallet: dw });
@@ -23056,7 +23338,8 @@ function DepositModal({
23056
23338
  assetCdnUrl: projectConfig?.asset_cdn_url,
23057
23339
  onEvent,
23058
23340
  onDepositSuccess,
23059
- onDepositError
23341
+ onDepositError,
23342
+ prefilledAmountUsd: normalizedPrefilledAmountUsd
23060
23343
  }
23061
23344
  ),
23062
23345
  depositPoweredByFooter
@@ -23068,7 +23351,7 @@ function DepositModal({
23068
23351
  title: "Deposit with Link",
23069
23352
  showBack: stripeLinkStep !== "checkout" && stripeLinkStep !== "success",
23070
23353
  onBack: handleBack,
23071
- showClose: stripeLinkStep !== "checkout",
23354
+ showClose: stripeLinkStep !== "checkout" && stripeLinkStep !== "auth",
23072
23355
  onClose: handleClose
23073
23356
  }
23074
23357
  ),
@@ -23099,6 +23382,8 @@ function DepositModal({
23099
23382
  destinationChainType,
23100
23383
  destinationChainId,
23101
23384
  destinationTokenAddress,
23385
+ countryCode: userIpInfo?.alpha2,
23386
+ subdivisionCode: userIpInfo?.subdivisionCode ?? void 0,
23102
23387
  wallets,
23103
23388
  email: userEmail,
23104
23389
  iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/link.svg` : void 0,
@@ -23138,6 +23423,7 @@ function DepositModal({
23138
23423
  onEvent,
23139
23424
  onDepositSuccess: onDepositSuccessFor("cashapp"),
23140
23425
  onDepositError: onDepositErrorFor("cashapp"),
23426
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
23141
23427
  wallets
23142
23428
  }
23143
23429
  ),
@@ -23195,16 +23481,16 @@ function DepositModal({
23195
23481
  }
23196
23482
 
23197
23483
  // src/components/checkout/CheckoutModal.tsx
23198
- import { useState as useState41, useEffect as useEffect35, useLayoutEffect as useLayoutEffect3, useCallback as useCallback9, useRef as useRef13, useMemo as useMemo14 } from "react";
23484
+ import { useState as useState41, useEffect as useEffect35, useLayoutEffect as useLayoutEffect3, useCallback as useCallback11, useRef as useRef14, useMemo as useMemo15 } from "react";
23199
23485
  import { AlertTriangle as AlertTriangle4, ChevronRight as ChevronRight19 } from "lucide-react";
23200
23486
 
23201
23487
  // src/hooks/use-payment-intent.ts
23202
- import { useQuery as useQuery17 } from "@tanstack/react-query";
23488
+ import { useQuery as useQuery18 } from "@tanstack/react-query";
23203
23489
  import { retrievePaymentIntent } from "@unifold/core";
23204
23490
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "expired", "refunded", "canceled"]);
23205
23491
  function usePaymentIntent(params) {
23206
23492
  const { clientSecret, publishableKey, enabled = true, pollingInterval = 3e3 } = params;
23207
- return useQuery17({
23493
+ return useQuery18({
23208
23494
  queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
23209
23495
  queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
23210
23496
  enabled: enabled && !!clientSecret && !!publishableKey,
@@ -23294,11 +23580,11 @@ function CheckoutModal({
23294
23580
  }) {
23295
23581
  const { colors: colors2, fonts, components } = useTheme();
23296
23582
  const [view, setView] = useState41("main");
23297
- const resetViewTimeoutRef = useRef13(null);
23583
+ const resetViewTimeoutRef = useRef14(null);
23298
23584
  const [browserWalletInfo, setBrowserWalletInfo] = useState41(null);
23299
23585
  const [browserWalletChainType, setBrowserWalletChainType] = useState41(() => getStoredWalletState()?.chainType);
23300
- const lastCheckoutMethodRef = useRef13(void 0);
23301
- const emitCheckoutSuccess = useCallback9(
23586
+ const lastCheckoutMethodRef = useRef14(void 0);
23587
+ const emitCheckoutSuccess = useCallback11(
23302
23588
  (data, method) => {
23303
23589
  const isSucceeded = data.status === "succeeded";
23304
23590
  const richIntent = isSucceeded && data.paymentIntent ? mapToCheckoutPaymentIntent(data.paymentIntent) : void 0;
@@ -23361,7 +23647,7 @@ function CheckoutModal({
23361
23647
  setView("main");
23362
23648
  }
23363
23649
  }, [showConnectWallet, showTransferCrypto, view]);
23364
- const prevStatusRef = useRef13(null);
23650
+ const prevStatusRef = useRef14(null);
23365
23651
  useEffect35(() => {
23366
23652
  if (!paymentIntent) return;
23367
23653
  const prev = prevStatusRef.current;
@@ -23380,11 +23666,11 @@ function CheckoutModal({
23380
23666
  );
23381
23667
  }
23382
23668
  }, [emitCheckoutSuccess, paymentIntent, view]);
23383
- const wallets = useMemo14(() => {
23669
+ const wallets = useMemo15(() => {
23384
23670
  if (!paymentIntent) return [];
23385
23671
  return mapDepositAddressesToWallets(paymentIntent.deposit_addresses, paymentIntent);
23386
23672
  }, [paymentIntent]);
23387
- const formatCryptoAmount = useMemo14(() => {
23673
+ const formatCryptoAmount = useMemo15(() => {
23388
23674
  if (!paymentIntent) return (_) => "";
23389
23675
  const decimals = paymentIntent.destination_token_decimals ?? 6;
23390
23676
  const symbol = paymentIntent.currency.toUpperCase();
@@ -23394,7 +23680,7 @@ function CheckoutModal({
23394
23680
  return `${formatted} ${symbol}`;
23395
23681
  };
23396
23682
  }, [paymentIntent]);
23397
- const remainingAmountUsd = useMemo14(() => {
23683
+ const remainingAmountUsd = useMemo15(() => {
23398
23684
  if (!paymentIntent) return void 0;
23399
23685
  const total = parseFloat(paymentIntent.destination_amount_usd || paymentIntent.amount_usd);
23400
23686
  const received = parseFloat(
@@ -23406,7 +23692,7 @@ function CheckoutModal({
23406
23692
  return remaining > 0 ? remaining.toFixed(2) : "0.00";
23407
23693
  }, [paymentIntent]);
23408
23694
  const [selectedSource, setSelectedSource] = useState41(null);
23409
- const remainingDestinationAmount = useMemo14(() => {
23695
+ const remainingDestinationAmount = useMemo15(() => {
23410
23696
  if (!paymentIntent) return "0";
23411
23697
  const remaining = BigInt(paymentIntent.destination_amount) - BigInt(paymentIntent.destination_amount_received);
23412
23698
  return remaining > 0n ? remaining.toString() : "0";
@@ -23428,7 +23714,7 @@ function CheckoutModal({
23428
23714
  stablecoinParity: paymentIntent?.stablecoin_parity ?? false,
23429
23715
  enabled: open && view === "transfer" && !!paymentIntent && !!selectedSource && remainingDestinationAmount !== "0"
23430
23716
  });
23431
- const effectiveCheckoutQuote = useMemo14(() => {
23717
+ const effectiveCheckoutQuote = useMemo15(() => {
23432
23718
  if (!sourceQuote || !selectedSource) return null;
23433
23719
  const baseQuote = {
23434
23720
  sourceAmount: sourceQuote.source_amount,
@@ -23449,7 +23735,7 @@ function CheckoutModal({
23449
23735
  sourceAmountUsd: minUsd.toFixed(2)
23450
23736
  };
23451
23737
  }, [sourceQuote, selectedSource]);
23452
- const handleBrowserWalletClick = useCallback9(
23738
+ const handleBrowserWalletClick = useCallback11(
23453
23739
  (walletInfo) => {
23454
23740
  const walletChainType = walletInfo.type === "phantom-solana" || walletInfo.type === "solflare" || walletInfo.type === "backpack" || walletInfo.type === "glow" ? "solana" : "ethereum";
23455
23741
  setStoredWalletState(walletInfo.type);
@@ -23472,19 +23758,19 @@ function CheckoutModal({
23472
23758
  },
23473
23759
  [wallets, onCheckoutError]
23474
23760
  );
23475
- const handleWalletConnectClick = useCallback9(() => {
23761
+ const handleWalletConnectClick = useCallback11(() => {
23476
23762
  setBrowserWalletInfo(null);
23477
23763
  lastCheckoutMethodRef.current = "wallet_connect";
23478
23764
  setView("wallet_connect");
23479
23765
  }, []);
23480
- const handleWalletDisconnect = useCallback9(() => {
23766
+ const handleWalletDisconnect = useCallback11(() => {
23481
23767
  setUserDisconnectedWallet(true);
23482
23768
  clearStoredWalletState();
23483
23769
  setBrowserWalletChainType(void 0);
23484
23770
  setBrowserWalletInfo(null);
23485
23771
  setView("main");
23486
23772
  }, []);
23487
- const handleClose = useCallback9(() => {
23773
+ const handleClose = useCallback11(() => {
23488
23774
  onOpenChange(false);
23489
23775
  if (resetViewTimeoutRef.current) {
23490
23776
  clearTimeout(resetViewTimeoutRef.current);
@@ -23514,7 +23800,7 @@ function CheckoutModal({
23514
23800
  },
23515
23801
  []
23516
23802
  );
23517
- const handleBack = useCallback9(() => {
23803
+ const handleBack = useCallback11(() => {
23518
23804
  setView("main");
23519
23805
  }, []);
23520
23806
  const poweredByFooter = /* @__PURE__ */ jsx64("div", { className: "uf-pt-3", children: /* @__PURE__ */ jsx64(
@@ -23852,7 +24138,7 @@ function CheckoutModal({
23852
24138
  userId: paymentIntent.user_id || "",
23853
24139
  publishableKey,
23854
24140
  clientSecret,
23855
- prefillAmountUsd: remainingAmountUsd,
24141
+ prefilledAmountUsd: remainingAmountUsd,
23856
24142
  checkoutAmountUsd: paymentIntent.amount_usd,
23857
24143
  checkoutReceivedUsd: paymentIntent.amount_received_usd,
23858
24144
  checkoutDestination: {
@@ -23914,16 +24200,16 @@ function CheckoutModal({
23914
24200
  }
23915
24201
 
23916
24202
  // src/components/withdrawals/WithdrawModal.tsx
23917
- import { useState as useState45, useEffect as useEffect39, useLayoutEffect as useLayoutEffect4, useCallback as useCallback11, useRef as useRef15 } from "react";
24203
+ import { useState as useState45, useEffect as useEffect39, useLayoutEffect as useLayoutEffect4, useCallback as useCallback13, useRef as useRef16 } from "react";
23918
24204
  import { AlertTriangle as AlertTriangle6, ChevronRight as ChevronRight21, Clock as Clock6 } from "lucide-react";
23919
24205
 
23920
24206
  // src/hooks/use-supported-destination-tokens.ts
23921
- import { useQuery as useQuery18 } from "@tanstack/react-query";
24207
+ import { useQuery as useQuery19 } from "@tanstack/react-query";
23922
24208
  import {
23923
24209
  getSupportedDestinationTokens
23924
24210
  } from "@unifold/core";
23925
24211
  function useSupportedDestinationTokens(publishableKey, enabled = true) {
23926
- return useQuery18({
24212
+ return useQuery19({
23927
24213
  queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
23928
24214
  queryFn: () => getSupportedDestinationTokens(publishableKey),
23929
24215
  staleTime: 1e3 * 60 * 5,
@@ -23952,7 +24238,7 @@ function useDefaultDestinationToken({
23952
24238
  }
23953
24239
 
23954
24240
  // src/hooks/use-source-token-validation.ts
23955
- import { useQuery as useQuery19 } from "@tanstack/react-query";
24241
+ import { useQuery as useQuery20 } from "@tanstack/react-query";
23956
24242
  import { getSupportedDepositTokens as getSupportedDepositTokens3 } from "@unifold/core";
23957
24243
  function useSourceTokenValidation(params) {
23958
24244
  const {
@@ -23964,7 +24250,7 @@ function useSourceTokenValidation(params) {
23964
24250
  enabled = true
23965
24251
  } = params;
23966
24252
  const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
23967
- return useQuery19({
24253
+ return useQuery20({
23968
24254
  queryKey: [
23969
24255
  "unifold",
23970
24256
  "sourceTokenValidation",
@@ -24012,12 +24298,12 @@ function useSourceTokenValidation(params) {
24012
24298
  }
24013
24299
 
24014
24300
  // src/hooks/use-address-balance.ts
24015
- import { useQuery as useQuery20 } from "@tanstack/react-query";
24301
+ import { useQuery as useQuery21 } from "@tanstack/react-query";
24016
24302
  import { getAddressBalance as getAddressBalance2 } from "@unifold/core";
24017
24303
  function useAddressBalance(params) {
24018
24304
  const { address, chainType, chainId, tokenAddress, publishableKey, enabled = true } = params;
24019
24305
  const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
24020
- return useQuery20({
24306
+ return useQuery21({
24021
24307
  queryKey: [
24022
24308
  "unifold",
24023
24309
  "addressBalance",
@@ -24073,11 +24359,11 @@ function useAddressBalance(params) {
24073
24359
  }
24074
24360
 
24075
24361
  // src/hooks/use-executions.ts
24076
- import { useQuery as useQuery21 } from "@tanstack/react-query";
24362
+ import { useQuery as useQuery22 } from "@tanstack/react-query";
24077
24363
  import { queryExecutions as queryExecutions4, ActionType as ActionType4 } from "@unifold/core";
24078
24364
  function useExecutions(userId, publishableKey, options) {
24079
24365
  const actionType = options?.actionType ?? ActionType4.Deposit;
24080
- return useQuery21({
24366
+ return useQuery22({
24081
24367
  queryKey: ["unifold", "executions", actionType, userId, publishableKey],
24082
24368
  queryFn: () => queryExecutions4(userId, publishableKey, actionType),
24083
24369
  enabled: (options?.enabled ?? true) && !!userId,
@@ -24089,7 +24375,7 @@ function useExecutions(userId, publishableKey, options) {
24089
24375
  }
24090
24376
 
24091
24377
  // src/hooks/use-withdraw-polling.ts
24092
- import { useState as useState42, useEffect as useEffect36, useRef as useRef14 } from "react";
24378
+ import { useState as useState42, useEffect as useEffect36, useRef as useRef15 } from "react";
24093
24379
  import {
24094
24380
  queryExecutions as queryExecutions5,
24095
24381
  pollDirectExecutions as pollDirectExecutions2,
@@ -24136,11 +24422,11 @@ function useWithdrawPolling({
24136
24422
  });
24137
24423
  const [executions, setExecutions] = useState42([]);
24138
24424
  const [isPolling, setIsPolling] = useState42(false);
24139
- const enabledAtRef = useRef14(/* @__PURE__ */ new Date());
24140
- const trackedRef = useRef14(/* @__PURE__ */ new Map());
24141
- const prevEnabledRef = useRef14(false);
24142
- const onSuccessRef = useRef14(onWithdrawSuccess);
24143
- const onErrorRef = useRef14(onWithdrawError);
24425
+ const enabledAtRef = useRef15(/* @__PURE__ */ new Date());
24426
+ const trackedRef = useRef15(/* @__PURE__ */ new Map());
24427
+ const prevEnabledRef = useRef15(false);
24428
+ const onSuccessRef = useRef15(onWithdrawSuccess);
24429
+ const onErrorRef = useRef15(onWithdrawError);
24144
24430
  useEffect36(() => {
24145
24431
  onSuccessRef.current = onWithdrawSuccess;
24146
24432
  }, [onWithdrawSuccess]);
@@ -24408,7 +24694,7 @@ function WithdrawDoubleInput({
24408
24694
  }
24409
24695
 
24410
24696
  // src/components/withdrawals/WithdrawForm.tsx
24411
- import { useState as useState43, useCallback as useCallback10, useMemo as useMemo16, useEffect as useEffect37 } from "react";
24697
+ import { useState as useState43, useCallback as useCallback12, useMemo as useMemo17, useEffect as useEffect37 } from "react";
24412
24698
  import {
24413
24699
  AlertTriangle as AlertTriangle5,
24414
24700
  ArrowUpDown,
@@ -24426,7 +24712,7 @@ import {
24426
24712
  } from "@unifold/core";
24427
24713
 
24428
24714
  // src/hooks/use-verify-recipient-address.ts
24429
- import { useQuery as useQuery22 } from "@tanstack/react-query";
24715
+ import { useQuery as useQuery23 } from "@tanstack/react-query";
24430
24716
  import { verifyRecipientAddress as verifyRecipientAddress2 } from "@unifold/core";
24431
24717
  function useVerifyRecipientAddress(params) {
24432
24718
  const {
@@ -24439,7 +24725,7 @@ function useVerifyRecipientAddress(params) {
24439
24725
  } = params;
24440
24726
  const trimmedAddress = recipientAddress?.trim() || "";
24441
24727
  const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
24442
- return useQuery22({
24728
+ return useQuery23({
24443
24729
  queryKey: [
24444
24730
  "unifold",
24445
24731
  "verifyRecipientAddress",
@@ -24686,11 +24972,11 @@ async function detectBrowserWallet(chainType, senderAddress) {
24686
24972
  }
24687
24973
 
24688
24974
  // src/hooks/use-hypercore-withdraw-activation.ts
24689
- import { useMemo as useMemo15 } from "react";
24975
+ import { useMemo as useMemo16 } from "react";
24690
24976
  import { ActionType as ActionType6 } from "@unifold/core";
24691
24977
 
24692
24978
  // src/hooks/use-get-deposit-address.ts
24693
- import { useQuery as useQuery23 } from "@tanstack/react-query";
24979
+ import { useQuery as useQuery24 } from "@tanstack/react-query";
24694
24980
  import { getDepositAddress } from "@unifold/core";
24695
24981
  function useGetDepositAddress(params) {
24696
24982
  const {
@@ -24704,7 +24990,7 @@ function useGetDepositAddress(params) {
24704
24990
  enabled = true
24705
24991
  } = params;
24706
24992
  const canFire = !!userId && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
24707
- return useQuery23({
24993
+ return useQuery24({
24708
24994
  queryKey: [
24709
24995
  "unifold",
24710
24996
  "getDepositAddress",
@@ -24773,7 +25059,7 @@ function useHypercoreWithdrawActivation(params) {
24773
25059
  actionType: ActionType6.Withdraw,
24774
25060
  enabled: enabled && isHypercore(sourceChainId)
24775
25061
  });
24776
- const depositWalletAddress = useMemo15(() => {
25062
+ const depositWalletAddress = useMemo16(() => {
24777
25063
  const wallets = depositWalletLookup.data?.data ?? [];
24778
25064
  return wallets.find((w) => w.chain_type === sourceChainType)?.address;
24779
25065
  }, [depositWalletLookup.data, sourceChainType]);
@@ -24895,7 +25181,7 @@ function WithdrawForm({
24895
25181
  enabled: debouncedAddress.length > 5 && !!selectedChain
24896
25182
  });
24897
25183
  const isDebouncing = trimmedAddress !== debouncedAddress;
24898
- const addressError = useMemo16(() => {
25184
+ const addressError = useMemo17(() => {
24899
25185
  if (!trimmedAddress || trimmedAddress.length <= 5) return null;
24900
25186
  if (isDebouncing || isVerifyingAddress) return null;
24901
25187
  if (verifyError) return t10.invalidAddress;
@@ -24929,33 +25215,33 @@ function WithdrawForm({
24929
25215
  destinationTokenAddress: selectedChain?.token_address,
24930
25216
  enabled: isAddressValid
24931
25217
  });
24932
- const exchangeRate = useMemo16(() => {
25218
+ const exchangeRate = useMemo17(() => {
24933
25219
  if (!balanceData?.exchangeRate) return 0;
24934
25220
  return parseFloat(balanceData.exchangeRate);
24935
25221
  }, [balanceData]);
24936
- const balanceCrypto = useMemo16(() => {
25222
+ const balanceCrypto = useMemo17(() => {
24937
25223
  if (!balanceData?.balanceHuman) return 0;
24938
25224
  return parseFloat(balanceData.balanceHuman);
24939
25225
  }, [balanceData]);
24940
- const balanceUsdNum = useMemo16(() => {
25226
+ const balanceUsdNum = useMemo17(() => {
24941
25227
  if (!balanceData?.balanceUsd) return 0;
24942
25228
  return parseFloat(balanceData.balanceUsd);
24943
25229
  }, [balanceData]);
24944
25230
  const tokenSymbol = sourceTokenSymbol || balanceData?.symbol || "TOKEN";
24945
25231
  const sourceDecimals = balanceData?.decimals ?? 6;
24946
- const cryptoAmountFromInput = useMemo16(() => {
25232
+ const cryptoAmountFromInput = useMemo17(() => {
24947
25233
  const val = parseFloat(amount);
24948
25234
  if (!val || val <= 0) return 0;
24949
25235
  if (inputUnit === "crypto") return val;
24950
25236
  return exchangeRate > 0 ? val / exchangeRate : 0;
24951
25237
  }, [amount, inputUnit, exchangeRate]);
24952
- const fiatAmountFromInput = useMemo16(() => {
25238
+ const fiatAmountFromInput = useMemo17(() => {
24953
25239
  const val = parseFloat(amount);
24954
25240
  if (!val || val <= 0) return 0;
24955
25241
  if (inputUnit === "fiat") return val;
24956
25242
  return val * exchangeRate;
24957
25243
  }, [amount, inputUnit, exchangeRate]);
24958
- const convertedDisplay = useMemo16(() => {
25244
+ const convertedDisplay = useMemo17(() => {
24959
25245
  if (!amount || parseFloat(amount) <= 0) return null;
24960
25246
  if (inputUnit === "crypto") {
24961
25247
  return `$${fiatAmountFromInput.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
@@ -24974,7 +25260,7 @@ function WithdrawForm({
24974
25260
  isMaxed,
24975
25261
  isStablecoin
24976
25262
  ]);
24977
- const balanceDisplay = useMemo16(() => {
25263
+ const balanceDisplay = useMemo17(() => {
24978
25264
  if (isLoadingBalance || !balanceData) return null;
24979
25265
  if (inputUnit === "crypto") {
24980
25266
  const displayDecimals = isStablecoin ? 2 : 6;
@@ -24997,7 +25283,7 @@ function WithdrawForm({
24997
25283
  tokenSymbol,
24998
25284
  isStablecoin
24999
25285
  ]);
25000
- const handleSwitchUnit = useCallback10(() => {
25286
+ const handleSwitchUnit = useCallback12(() => {
25001
25287
  if (isMaxed && balanceData) {
25002
25288
  if (inputUnit === "crypto") {
25003
25289
  setAmount((Math.round(balanceUsdNum * 100) / 100).toFixed(2));
@@ -25024,7 +25310,7 @@ function WithdrawForm({
25024
25310
  setInputUnit("crypto");
25025
25311
  }
25026
25312
  }, [amount, inputUnit, exchangeRate, sourceDecimals, isMaxed, balanceData, balanceUsdNum]);
25027
- const handleMaxClick = useCallback10(() => {
25313
+ const handleMaxClick = useCallback12(() => {
25028
25314
  if (inputUnit === "crypto") {
25029
25315
  if (balanceCrypto <= 0) return;
25030
25316
  setAmount(balanceData?.balanceHuman ?? "0");
@@ -25038,7 +25324,7 @@ function WithdrawForm({
25038
25324
  const isBelowMinimum = minimumWithdrawAmountUsd !== null && fiatAmountFromInput > 0 && Math.round(fiatAmountFromInput * 100) / 100 < minimumWithdrawAmountUsd;
25039
25325
  const isOverBalance = inputUnit === "crypto" ? cryptoAmountFromInput > 0 && balanceCrypto > 0 && cryptoAmountFromInput > balanceCrypto : fiatAmountFromInput > 0 && balanceUsdNum > 0 && Math.round(fiatAmountFromInput * 100) / 100 > Math.round(balanceUsdNum * 100) / 100;
25040
25326
  const isFormValid = trimmedAddress.length > 0 && amount.trim().length > 0 && cryptoAmountFromInput > 0 && isAddressValid && !isBelowMinimum && !isOverBalance && !isBalanceBelowMinimum && !!balanceData;
25041
- const handleWithdraw = useCallback10(async () => {
25327
+ const handleWithdraw = useCallback12(async () => {
25042
25328
  if (!selectedToken || !selectedChain) return;
25043
25329
  if (!isFormValid) return;
25044
25330
  setIsSubmitting(true);
@@ -25824,7 +26110,7 @@ function WithdrawModal({
25824
26110
  theme = "dark",
25825
26111
  hideOverlay = false
25826
26112
  }) {
25827
- const onWithdrawSuccessFor = useCallback11(
26113
+ const onWithdrawSuccessFor = useCallback13(
25828
26114
  (data) => {
25829
26115
  onWithdrawSuccess?.(data);
25830
26116
  if (data.execution) {
@@ -25835,7 +26121,7 @@ function WithdrawModal({
25835
26121
  );
25836
26122
  const { colors: colors2, fonts, components } = useTheme();
25837
26123
  const [containerEl, setContainerEl] = useState45(null);
25838
- const containerCallbackRef = useCallback11((el) => {
26124
+ const containerCallbackRef = useCallback13((el) => {
25839
26125
  setContainerEl(el);
25840
26126
  }, []);
25841
26127
  const [resolvedTheme, setResolvedTheme] = useState45(
@@ -25908,7 +26194,7 @@ function WithdrawModal({
25908
26194
  refetchInterval: view === "tracker" || view === "detail" ? 5e3 : 15e3
25909
26195
  });
25910
26196
  const allWithdrawals = allWithdrawalsData?.data ?? [];
25911
- const handleDepositWalletCreation = useCallback11(
26197
+ const handleDepositWalletCreation = useCallback13(
25912
26198
  async (params) => {
25913
26199
  const { data: wallets } = await createDepositAddress2(
25914
26200
  {
@@ -25931,12 +26217,12 @@ function WithdrawModal({
25931
26217
  },
25932
26218
  [externalUserId, publishableKey, sourceChainType]
25933
26219
  );
25934
- const handleWithdrawSubmitted = useCallback11((txInfo) => {
26220
+ const handleWithdrawSubmitted = useCallback13((txInfo) => {
25935
26221
  setSubmittedTxInfo(txInfo);
25936
26222
  setView("confirming");
25937
26223
  }, []);
25938
- const resetViewTimeoutRef = useRef15(null);
25939
- const handleClose = useCallback11(() => {
26224
+ const resetViewTimeoutRef = useRef16(null);
26225
+ const handleClose = useCallback13(() => {
25940
26226
  onOpenChange(false);
25941
26227
  if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
25942
26228
  resetViewTimeoutRef.current = setTimeout(() => {
@@ -25964,13 +26250,13 @@ function WithdrawModal({
25964
26250
  },
25965
26251
  []
25966
26252
  );
25967
- const handleTokenSymbolChange = useCallback11(
26253
+ const handleTokenSymbolChange = useCallback13(
25968
26254
  (symbol) => {
25969
26255
  setSelectedTokenSymbol(symbol);
25970
26256
  },
25971
26257
  [setSelectedTokenSymbol]
25972
26258
  );
25973
- const handleChainKeyChange = useCallback11(
26259
+ const handleChainKeyChange = useCallback13(
25974
26260
  (chainKey) => {
25975
26261
  setSelectedChainKey(chainKey);
25976
26262
  },
@@ -26157,7 +26443,7 @@ function WithdrawModal({
26157
26443
  }
26158
26444
 
26159
26445
  // src/components/withdrawals/WithdrawTokenSelector.tsx
26160
- import { useState as useState46, useMemo as useMemo17 } from "react";
26446
+ import { useState as useState46, useMemo as useMemo18 } from "react";
26161
26447
  import { Search } from "lucide-react";
26162
26448
  import Fuse2 from "fuse.js";
26163
26449
  import { jsx as jsx70, jsxs as jsxs64 } from "react/jsx-runtime";
@@ -26166,7 +26452,7 @@ function WithdrawTokenSelector({ tokens, onSelect, onBack }) {
26166
26452
  const { themeClass, colors: colors2, fonts, components } = useTheme();
26167
26453
  const [searchQuery, setSearchQuery] = useState46("");
26168
26454
  const [hoveredKey, setHoveredKey] = useState46(null);
26169
- const allOptions = useMemo17(() => {
26455
+ const allOptions = useMemo18(() => {
26170
26456
  const options = [];
26171
26457
  tokens.forEach((token) => {
26172
26458
  token.chains.forEach((chain) => {
@@ -26175,7 +26461,7 @@ function WithdrawTokenSelector({ tokens, onSelect, onBack }) {
26175
26461
  });
26176
26462
  return options;
26177
26463
  }, [tokens]);
26178
- const fuse = useMemo17(
26464
+ const fuse = useMemo18(
26179
26465
  () => new Fuse2(allOptions, {
26180
26466
  keys: [
26181
26467
  { name: "token.symbol", weight: 2 },
@@ -26188,7 +26474,7 @@ function WithdrawTokenSelector({ tokens, onSelect, onBack }) {
26188
26474
  }),
26189
26475
  [allOptions]
26190
26476
  );
26191
- const filteredOptions = useMemo17(() => {
26477
+ const filteredOptions = useMemo18(() => {
26192
26478
  if (!searchQuery.trim()) return allOptions;
26193
26479
  const query = searchQuery.trim();
26194
26480
  const results = fuse.search(query);