@unifold/connect-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.js CHANGED
@@ -6190,7 +6190,9 @@ var import_jsx_runtime18 = require("react/jsx-runtime");
6190
6190
  var React211 = __toESM(require("react"), 1);
6191
6191
  var import_jsx_runtime19 = require("react/jsx-runtime");
6192
6192
  var import_jsx_runtime20 = require("react/jsx-runtime");
6193
+ var React52 = __toESM(require("react"), 1);
6193
6194
  var import_react9 = require("react");
6195
+ var import_react_query3 = require("@tanstack/react-query");
6194
6196
 
6195
6197
  // ../core/dist/index.mjs
6196
6198
  var import_react_query2 = require("@tanstack/react-query");
@@ -6484,6 +6486,27 @@ async function getFiatCurrencies(publishableKey) {
6484
6486
  }
6485
6487
  return response.json();
6486
6488
  }
6489
+ async function getFiatExchangeRates(options = {}, publishableKey) {
6490
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
6491
+ validatePublishableKey(pk);
6492
+ const params = new URLSearchParams();
6493
+ if (options.currencies && options.currencies.length > 0) {
6494
+ params.set("currencies", options.currencies.join(","));
6495
+ }
6496
+ const queryString = params.toString();
6497
+ const url = `${API_BASE_URL}/v1/public/exchange_rates/fiat_currencies${queryString ? `?${queryString}` : ""}`;
6498
+ const response = await fetch(url, {
6499
+ method: "GET",
6500
+ headers: {
6501
+ accept: "application/json",
6502
+ "x-publishable-key": pk
6503
+ }
6504
+ });
6505
+ if (!response.ok) {
6506
+ throw new Error(`Failed to fetch fiat exchange rates: ${response.statusText}`);
6507
+ }
6508
+ return response.json();
6509
+ }
6487
6510
  async function getOnrampQuotes(request, publishableKey) {
6488
6511
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
6489
6512
  validatePublishableKey(pk);
@@ -7165,6 +7188,7 @@ async function stripeGetDefaultToken(params, publishableKey) {
7165
7188
  chain_type: params.chainType
7166
7189
  });
7167
7190
  if (params.countryCode) query.append("country_code", params.countryCode);
7191
+ if (params.subdivisionCode) query.append("subdivision_code", params.subdivisionCode);
7168
7192
  const response = await fetch(
7169
7193
  `${API_BASE_URL}${HEADLESS_STRIPE_BASE}/default_token?${query.toString()}`,
7170
7194
  {
@@ -7803,7 +7827,7 @@ var en_default = {
7803
7827
  var i18n = en_default;
7804
7828
 
7805
7829
  // ../ui-react/dist/index.mjs
7806
- var import_react_query3 = require("@tanstack/react-query");
7830
+ var import_react_query4 = require("@tanstack/react-query");
7807
7831
  var import_react10 = require("react");
7808
7832
  var import_react11 = require("react");
7809
7833
  var import_react12 = require("react");
@@ -7812,7 +7836,7 @@ var React42 = __toESM(require("react"), 1);
7812
7836
  var import_jsx_runtime22 = require("react/jsx-runtime");
7813
7837
  var import_jsx_runtime23 = require("react/jsx-runtime");
7814
7838
  var import_jsx_runtime24 = require("react/jsx-runtime");
7815
- var import_react_query4 = require("@tanstack/react-query");
7839
+ var import_react_query5 = require("@tanstack/react-query");
7816
7840
  var import_react13 = require("react");
7817
7841
  var import_jsx_runtime25 = require("react/jsx-runtime");
7818
7842
  var import_react14 = require("react");
@@ -7822,12 +7846,12 @@ var import_jsx_runtime26 = require("react/jsx-runtime");
7822
7846
  var import_jsx_runtime27 = require("react/jsx-runtime");
7823
7847
  var import_jsx_runtime28 = require("react/jsx-runtime");
7824
7848
  var import_jsx_runtime29 = require("react/jsx-runtime");
7825
- var React52 = __toESM(require("react"), 1);
7849
+ var React62 = __toESM(require("react"), 1);
7826
7850
  var import_react17 = require("react");
7827
- var import_react_query5 = require("@tanstack/react-query");
7828
- var import_react18 = require("react");
7829
7851
  var import_react_query6 = require("@tanstack/react-query");
7852
+ var import_react18 = require("react");
7830
7853
  var import_react_query7 = require("@tanstack/react-query");
7854
+ var import_react_query8 = require("@tanstack/react-query");
7831
7855
  var import_jsx_runtime30 = require("react/jsx-runtime");
7832
7856
  var import_react19 = require("react");
7833
7857
  var import_jsx_runtime31 = require("react/jsx-runtime");
@@ -7836,20 +7860,20 @@ var import_react21 = require("react");
7836
7860
  var import_qr_code_styling = __toESM(require_qr_code_styling(), 1);
7837
7861
  var import_jsx_runtime32 = require("react/jsx-runtime");
7838
7862
  var import_react22 = require("react");
7839
- var import_react_query8 = require("@tanstack/react-query");
7863
+ var import_react_query9 = require("@tanstack/react-query");
7840
7864
  var import_jsx_runtime33 = require("react/jsx-runtime");
7841
7865
  var import_react23 = require("react");
7842
- var import_react_query9 = require("@tanstack/react-query");
7866
+ var import_react_query10 = require("@tanstack/react-query");
7843
7867
  var import_jsx_runtime34 = require("react/jsx-runtime");
7844
7868
  var import_jsx_runtime35 = require("react/jsx-runtime");
7845
- var React62 = __toESM(require("react"), 1);
7846
- var import_jsx_runtime36 = require("react/jsx-runtime");
7847
7869
  var React72 = __toESM(require("react"), 1);
7848
- var import_jsx_runtime37 = require("react/jsx-runtime");
7870
+ var import_jsx_runtime36 = require("react/jsx-runtime");
7849
7871
  var React82 = __toESM(require("react"), 1);
7872
+ var import_jsx_runtime37 = require("react/jsx-runtime");
7873
+ var React92 = __toESM(require("react"), 1);
7850
7874
  var import_jsx_runtime38 = require("react/jsx-runtime");
7875
+ var React112 = __toESM(require("react"), 1);
7851
7876
  var React102 = __toESM(require("react"), 1);
7852
- var React92 = __toESM(require("react"), 1);
7853
7877
 
7854
7878
  // ../../node_modules/.pnpm/@radix-ui+react-slot@1.2.4_@types+react@19.2.9_react@19.2.3/node_modules/@radix-ui/react-slot/dist/index.mjs
7855
7879
  var React25 = __toESM(require("react"), 1);
@@ -7997,15 +8021,15 @@ var cva = (base, config) => (props) => {
7997
8021
  // ../ui-react/dist/index.mjs
7998
8022
  var import_jsx_runtime39 = require("react/jsx-runtime");
7999
8023
  var import_jsx_runtime40 = require("react/jsx-runtime");
8000
- var React112 = __toESM(require("react"), 1);
8001
- var import_jsx_runtime41 = require("react/jsx-runtime");
8002
8024
  var React122 = __toESM(require("react"), 1);
8003
- var import_jsx_runtime42 = require("react/jsx-runtime");
8025
+ var import_jsx_runtime41 = require("react/jsx-runtime");
8004
8026
  var React132 = __toESM(require("react"), 1);
8005
- var import_jsx_runtime43 = require("react/jsx-runtime");
8027
+ var import_jsx_runtime42 = require("react/jsx-runtime");
8006
8028
  var React142 = __toESM(require("react"), 1);
8029
+ var import_jsx_runtime43 = require("react/jsx-runtime");
8030
+ var React152 = __toESM(require("react"), 1);
8007
8031
  var import_jsx_runtime44 = require("react/jsx-runtime");
8008
- var React282 = __toESM(require("react"), 1);
8032
+ var React292 = __toESM(require("react"), 1);
8009
8033
 
8010
8034
  // ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/utils.js
8011
8035
  function requestProviders(listener) {
@@ -8062,50 +8086,50 @@ function createStore() {
8062
8086
  }
8063
8087
 
8064
8088
  // ../ui-react/dist/index.mjs
8065
- var React152 = __toESM(require("react"), 1);
8066
8089
  var React162 = __toESM(require("react"), 1);
8067
- var import_jsx_runtime45 = require("react/jsx-runtime");
8068
8090
  var React172 = __toESM(require("react"), 1);
8069
- var import_jsx_runtime46 = require("react/jsx-runtime");
8091
+ var import_jsx_runtime45 = require("react/jsx-runtime");
8070
8092
  var React182 = __toESM(require("react"), 1);
8071
- var import_jsx_runtime47 = require("react/jsx-runtime");
8093
+ var import_jsx_runtime46 = require("react/jsx-runtime");
8072
8094
  var React192 = __toESM(require("react"), 1);
8073
- var import_jsx_runtime48 = require("react/jsx-runtime");
8095
+ var import_jsx_runtime47 = require("react/jsx-runtime");
8074
8096
  var React202 = __toESM(require("react"), 1);
8075
- var import_jsx_runtime49 = require("react/jsx-runtime");
8097
+ var import_jsx_runtime48 = require("react/jsx-runtime");
8076
8098
  var React212 = __toESM(require("react"), 1);
8077
- var import_jsx_runtime50 = require("react/jsx-runtime");
8099
+ var import_jsx_runtime49 = require("react/jsx-runtime");
8078
8100
  var React222 = __toESM(require("react"), 1);
8079
- var import_jsx_runtime51 = require("react/jsx-runtime");
8101
+ var import_jsx_runtime50 = require("react/jsx-runtime");
8080
8102
  var React232 = __toESM(require("react"), 1);
8081
- var import_jsx_runtime52 = require("react/jsx-runtime");
8103
+ var import_jsx_runtime51 = require("react/jsx-runtime");
8082
8104
  var React242 = __toESM(require("react"), 1);
8083
- var import_jsx_runtime53 = require("react/jsx-runtime");
8105
+ var import_jsx_runtime52 = require("react/jsx-runtime");
8084
8106
  var React252 = __toESM(require("react"), 1);
8085
- var import_jsx_runtime54 = require("react/jsx-runtime");
8107
+ var import_jsx_runtime53 = require("react/jsx-runtime");
8086
8108
  var React262 = __toESM(require("react"), 1);
8087
- var import_jsx_runtime55 = require("react/jsx-runtime");
8109
+ var import_jsx_runtime54 = require("react/jsx-runtime");
8088
8110
  var React272 = __toESM(require("react"), 1);
8111
+ var import_jsx_runtime55 = require("react/jsx-runtime");
8112
+ var React282 = __toESM(require("react"), 1);
8089
8113
  var import_jsx_runtime56 = require("react/jsx-runtime");
8090
8114
  var import_jsx_runtime57 = require("react/jsx-runtime");
8091
8115
  var import_jsx_runtime58 = require("react/jsx-runtime");
8092
- var React292 = __toESM(require("react"), 1);
8116
+ var React302 = __toESM(require("react"), 1);
8093
8117
  var import_jsx_runtime59 = require("react/jsx-runtime");
8094
8118
  var import_react24 = require("react");
8095
8119
  var import_jsx_runtime60 = require("react/jsx-runtime");
8096
8120
  var import_react25 = require("react");
8097
8121
  var import_jsx_runtime61 = require("react/jsx-runtime");
8098
8122
  var import_react26 = require("react");
8099
- var import_react_query10 = require("@tanstack/react-query");
8100
8123
  var import_react_query11 = require("@tanstack/react-query");
8101
8124
  var import_react_query12 = require("@tanstack/react-query");
8102
- var import_jsx_runtime62 = require("react/jsx-runtime");
8103
8125
  var import_react_query13 = require("@tanstack/react-query");
8126
+ var import_jsx_runtime62 = require("react/jsx-runtime");
8104
8127
  var import_react_query14 = require("@tanstack/react-query");
8105
8128
  var import_react_query15 = require("@tanstack/react-query");
8129
+ var import_react_query16 = require("@tanstack/react-query");
8106
8130
  var import_react27 = require("react");
8107
8131
  var import_react28 = require("react");
8108
- var React312 = __toESM(require("react"), 1);
8132
+ var React322 = __toESM(require("react"), 1);
8109
8133
  var import_jsx_runtime63 = require("react/jsx-runtime");
8110
8134
  var import_jsx_runtime64 = require("react/jsx-runtime");
8111
8135
  var import_jsx_runtime65 = require("react/jsx-runtime");
@@ -10115,7 +10139,7 @@ var import_react30 = require("react");
10115
10139
  var import_jsx_runtime67 = require("react/jsx-runtime");
10116
10140
  var import_jsx_runtime68 = require("react/jsx-runtime");
10117
10141
  var import_react31 = require("react");
10118
- var React322 = __toESM(require("react"), 1);
10142
+ var React332 = __toESM(require("react"), 1);
10119
10143
 
10120
10144
  // ../../node_modules/.pnpm/@radix-ui+react-tooltip@1.2.8_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2._udyjcec5g7ve3mpsxbgla63vgi/node_modules/@radix-ui/react-tooltip/dist/index.mjs
10121
10145
  var React31 = __toESM(require("react"), 1);
@@ -12853,11 +12877,11 @@ var Content22 = TooltipContent;
12853
12877
 
12854
12878
  // ../ui-react/dist/index.mjs
12855
12879
  var import_jsx_runtime69 = require("react/jsx-runtime");
12856
- var import_react_query16 = require("@tanstack/react-query");
12880
+ var import_react_query17 = require("@tanstack/react-query");
12857
12881
  var import_jsx_runtime70 = require("react/jsx-runtime");
12858
12882
  var import_jsx_runtime71 = require("react/jsx-runtime");
12859
12883
  var import_react32 = require("react");
12860
- var React332 = __toESM(require("react"), 1);
12884
+ var React342 = __toESM(require("react"), 1);
12861
12885
 
12862
12886
  // ../../node_modules/.pnpm/@radix-ui+react-select@2.2.6_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2.9_cot3leusltbsophitaz3dgdqdm/node_modules/@radix-ui/react-select/dist/index.mjs
12863
12887
  var React35 = __toESM(require("react"), 1);
@@ -14094,9 +14118,9 @@ var Separator = SelectSeparator;
14094
14118
  // ../ui-react/dist/index.mjs
14095
14119
  var import_jsx_runtime72 = require("react/jsx-runtime");
14096
14120
  var import_jsx_runtime73 = require("react/jsx-runtime");
14097
- var React342 = __toESM(require("react"), 1);
14098
- var import_react_query17 = require("@tanstack/react-query");
14121
+ var React352 = __toESM(require("react"), 1);
14099
14122
  var import_react_query18 = require("@tanstack/react-query");
14123
+ var import_react_query19 = require("@tanstack/react-query");
14100
14124
  var import_jsx_runtime74 = require("react/jsx-runtime");
14101
14125
  var import_jsx_runtime75 = require("react/jsx-runtime");
14102
14126
  var import_jsx_runtime76 = require("react/jsx-runtime");
@@ -14106,19 +14130,19 @@ var import_jsx_runtime78 = require("react/jsx-runtime");
14106
14130
  var import_jsx_runtime79 = require("react/jsx-runtime");
14107
14131
  var import_jsx_runtime80 = require("react/jsx-runtime");
14108
14132
  var import_react34 = require("react");
14109
- var import_react_query19 = require("@tanstack/react-query");
14133
+ var import_react_query20 = require("@tanstack/react-query");
14110
14134
  var import_jsx_runtime81 = require("react/jsx-runtime");
14111
14135
  var import_react35 = require("react");
14112
- var import_react_query20 = require("@tanstack/react-query");
14113
14136
  var import_react_query21 = require("@tanstack/react-query");
14114
14137
  var import_react_query22 = require("@tanstack/react-query");
14115
14138
  var import_react_query23 = require("@tanstack/react-query");
14139
+ var import_react_query24 = require("@tanstack/react-query");
14116
14140
  var import_react36 = require("react");
14117
14141
  var import_jsx_runtime82 = require("react/jsx-runtime");
14118
14142
  var import_react37 = require("react");
14119
- var import_react_query24 = require("@tanstack/react-query");
14120
- var import_react38 = require("react");
14121
14143
  var import_react_query25 = require("@tanstack/react-query");
14144
+ var import_react38 = require("react");
14145
+ var import_react_query26 = require("@tanstack/react-query");
14122
14146
  var import_jsx_runtime83 = require("react/jsx-runtime");
14123
14147
  var import_jsx_runtime84 = require("react/jsx-runtime");
14124
14148
  var import_react39 = require("react");
@@ -14675,7 +14699,7 @@ function useDepositAddress(params) {
14675
14699
  contractCalls,
14676
14700
  enabled = true
14677
14701
  } = params;
14678
- return (0, import_react_query3.useQuery)({
14702
+ return (0, import_react_query4.useQuery)({
14679
14703
  queryKey: [
14680
14704
  "unifold",
14681
14705
  "depositAddress",
@@ -15302,7 +15326,7 @@ function useUserIp2() {
15302
15326
  data: userIpInfo,
15303
15327
  isLoading,
15304
15328
  error
15305
- } = (0, import_react_query4.useQuery)({
15329
+ } = (0, import_react_query5.useQuery)({
15306
15330
  queryKey: ["unifold", "userIpInfo"],
15307
15331
  queryFn: async () => {
15308
15332
  const data = await getIpAddress();
@@ -16576,13 +16600,25 @@ function BuyWithCard({
16576
16600
  wallets: externalWallets,
16577
16601
  assetCdnUrl,
16578
16602
  hideDepositFlowInfo = false,
16579
- hideDisplayDescription = false
16603
+ hideDisplayDescription = false,
16604
+ prefilledAmountUsd
16580
16605
  }) {
16581
16606
  const { colors: colors2, fonts, components } = useTheme();
16582
- const [amount, setAmount] = (0, import_react9.useState)("");
16607
+ const cleanedPrefilledAmountUsd = React52.useMemo(() => {
16608
+ if (!prefilledAmountUsd) return "";
16609
+ return prefilledAmountUsd.replace(/[^0-9.]/g, "");
16610
+ }, [prefilledAmountUsd]);
16611
+ const parsedPrefilledAmountUsd = React52.useMemo(() => {
16612
+ const parsed = parseFloat(cleanedPrefilledAmountUsd);
16613
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
16614
+ }, [cleanedPrefilledAmountUsd]);
16615
+ const shouldAutoConvertPrefilledRef = (0, import_react9.useRef)(!!cleanedPrefilledAmountUsd);
16616
+ const [amount, setAmount] = (0, import_react9.useState)(() => cleanedPrefilledAmountUsd);
16583
16617
  const [currency, setCurrency] = (0, import_react9.useState)("usd");
16584
16618
  const [hasManualCurrencySelection, setHasManualCurrencySelection] = (0, import_react9.useState)(false);
16585
- const [hasManualAmountEntry, setHasManualAmountEntry] = (0, import_react9.useState)(false);
16619
+ const [hasManualAmountEntry, setHasManualAmountEntry] = (0, import_react9.useState)(
16620
+ () => !!cleanedPrefilledAmountUsd
16621
+ );
16586
16622
  const [showCurrencyModal, setShowCurrencyModal] = (0, import_react9.useState)(false);
16587
16623
  const [quotes, setQuotes] = (0, import_react9.useState)([]);
16588
16624
  const [quotesLoading, setQuotesLoading] = (0, import_react9.useState)(false);
@@ -16639,6 +16675,71 @@ function BuyWithCard({
16639
16675
  const [preferredCurrencyCodes, setPreferredCurrencyCodes] = (0, import_react9.useState)([]);
16640
16676
  const [currenciesLoading, setCurrenciesLoading] = (0, import_react9.useState)(true);
16641
16677
  const [destinationToken, setDestinationToken] = (0, import_react9.useState)(null);
16678
+ (0, import_react9.useEffect)(() => {
16679
+ const hasPrefilledAmount = !!cleanedPrefilledAmountUsd;
16680
+ shouldAutoConvertPrefilledRef.current = hasPrefilledAmount;
16681
+ if (!hasPrefilledAmount) return;
16682
+ setAmount(cleanedPrefilledAmountUsd);
16683
+ setHasManualAmountEntry(true);
16684
+ }, [cleanedPrefilledAmountUsd]);
16685
+ const { data: fiatExchangeRatesResponse, isLoading: isFiatExchangeRatesLoading } = (0, import_react_query3.useQuery)({
16686
+ queryKey: ["fiat-exchange-rates", publishableKey],
16687
+ staleTime: 3e4,
16688
+ refetchInterval: 3e4,
16689
+ queryFn: async () => {
16690
+ try {
16691
+ return await getFiatExchangeRates({}, publishableKey);
16692
+ } catch (error) {
16693
+ console.error("Error fetching fiat exchange rates:", error);
16694
+ return { base_currency: "usd", rates: {} };
16695
+ }
16696
+ }
16697
+ });
16698
+ const fiatExchangeRates = fiatExchangeRatesResponse?.rates ?? {};
16699
+ const convertAmountBetweenCurrencies = React52.useCallback(
16700
+ (rawAmount, fromCurrencyCode, toCurrencyCode) => {
16701
+ const parsedAmount = parseFloat(rawAmount);
16702
+ if (!Number.isFinite(parsedAmount) || parsedAmount <= 0) return null;
16703
+ const fromCode = fromCurrencyCode.toLowerCase();
16704
+ const toCode = toCurrencyCode.toLowerCase();
16705
+ const fromRate = fromCode === "usd" ? 1 : fiatExchangeRates[fromCode];
16706
+ const toRate = toCode === "usd" ? 1 : fiatExchangeRates[toCode];
16707
+ if (!Number.isFinite(fromRate) || fromRate <= 0) return null;
16708
+ if (!Number.isFinite(toRate) || toRate <= 0) return null;
16709
+ const usdAmount = parsedAmount / fromRate;
16710
+ return parseFloat((usdAmount * toRate).toFixed(2)).toString();
16711
+ },
16712
+ [fiatExchangeRates]
16713
+ );
16714
+ const getConvertedPrefilledAmount = React52.useCallback(
16715
+ (targetCurrencyCode) => {
16716
+ if (!parsedPrefilledAmountUsd) return null;
16717
+ const normalizedTargetCurrency = targetCurrencyCode.toLowerCase();
16718
+ const rate = normalizedTargetCurrency === "usd" ? 1 : fiatExchangeRates[normalizedTargetCurrency];
16719
+ if (!Number.isFinite(rate) || rate <= 0) return null;
16720
+ return parseFloat((parsedPrefilledAmountUsd * rate).toFixed(2)).toString();
16721
+ },
16722
+ [parsedPrefilledAmountUsd, fiatExchangeRates]
16723
+ );
16724
+ (0, import_react9.useEffect)(() => {
16725
+ if (!cleanedPrefilledAmountUsd || !shouldAutoConvertPrefilledRef.current) return;
16726
+ const convertedAmount = getConvertedPrefilledAmount(currency);
16727
+ if (!convertedAmount) {
16728
+ if (isFiatExchangeRatesLoading) return;
16729
+ const targetCurrency = currency.toLowerCase();
16730
+ if (targetCurrency !== "usd") {
16731
+ setCurrency("usd");
16732
+ }
16733
+ return;
16734
+ }
16735
+ setAmount(convertedAmount);
16736
+ setHasManualAmountEntry(true);
16737
+ }, [
16738
+ cleanedPrefilledAmountUsd,
16739
+ currency,
16740
+ getConvertedPrefilledAmount,
16741
+ isFiatExchangeRatesLoading
16742
+ ]);
16642
16743
  const depositWalletId = defaultToken ? getWalletByChainType(wallets, defaultToken.destination_token_metadata.chain_type)?.id : void 0;
16643
16744
  const { executions, isPolling, showWaitingUi } = useDepositPolling({
16644
16745
  userId,
@@ -16669,6 +16770,7 @@ function BuyWithCard({
16669
16770
  }, [publishableKey]);
16670
16771
  (0, import_react9.useEffect)(() => {
16671
16772
  if (hasManualCurrencySelection) return;
16773
+ if (hasManualAmountEntry && !shouldAutoConvertPrefilledRef.current) return;
16672
16774
  if (fiatCurrencies.length === 0 || !userIpInfo?.alpha2) return;
16673
16775
  const userCountryCode = userIpInfo.alpha2;
16674
16776
  const matchingCurrency = fiatCurrencies.find((c) => c.country_codes.includes(userCountryCode));
@@ -16687,7 +16789,15 @@ function BuyWithCard({
16687
16789
  const prevCurrencyRef = (0, import_react9.useRef)(null);
16688
16790
  (0, import_react9.useEffect)(() => {
16689
16791
  if (fiatCurrencies.length === 0) return;
16792
+ if (shouldAutoConvertPrefilledRef.current) {
16793
+ prevCurrencyRef.current = currency;
16794
+ return;
16795
+ }
16690
16796
  if (prevCurrencyRef.current !== null && prevCurrencyRef.current !== currency) {
16797
+ if (hasManualAmountEntry) {
16798
+ prevCurrencyRef.current = currency;
16799
+ return;
16800
+ }
16691
16801
  const currentCurrency = fiatCurrencies.find(
16692
16802
  (c) => c.currency_code.toLowerCase() === currency.toLowerCase()
16693
16803
  );
@@ -16696,7 +16806,7 @@ function BuyWithCard({
16696
16806
  }
16697
16807
  }
16698
16808
  prevCurrencyRef.current = currency;
16699
- }, [currency]);
16809
+ }, [currency, fiatCurrencies, hasManualAmountEntry]);
16700
16810
  (0, import_react9.useEffect)(() => {
16701
16811
  async function fetchDestinationToken() {
16702
16812
  try {
@@ -16873,6 +16983,7 @@ function BuyWithCard({
16873
16983
  return () => clearInterval(timer);
16874
16984
  }, [quotes.length, amount]);
16875
16985
  const handleAmountChange = (value) => {
16986
+ shouldAutoConvertPrefilledRef.current = false;
16876
16987
  if (value === "") {
16877
16988
  setAmount(value);
16878
16989
  setHasManualAmountEntry(true);
@@ -16886,6 +16997,7 @@ function BuyWithCard({
16886
16997
  }
16887
16998
  };
16888
16999
  const handleQuickAmount = (quickAmount) => {
17000
+ shouldAutoConvertPrefilledRef.current = false;
16889
17001
  setAmount(quickAmount.toString());
16890
17002
  setHasManualAmountEntry(true);
16891
17003
  };
@@ -17489,8 +17601,43 @@ function BuyWithCard({
17489
17601
  preferredCurrencyCodes,
17490
17602
  selectedCurrency: currency,
17491
17603
  onSelectCurrency: (currencyCode) => {
17492
- setCurrency(currencyCode.toLowerCase());
17604
+ const nextCurrency = currencyCode.toLowerCase();
17605
+ if (nextCurrency === currency.toLowerCase()) {
17606
+ setHasManualCurrencySelection(true);
17607
+ return;
17608
+ }
17609
+ const currentCurrency = currency;
17493
17610
  setHasManualCurrencySelection(true);
17611
+ if (shouldAutoConvertPrefilledRef.current) {
17612
+ const convertedAmount = getConvertedPrefilledAmount(nextCurrency);
17613
+ if (convertedAmount) {
17614
+ setCurrency(nextCurrency);
17615
+ setAmount(convertedAmount);
17616
+ setHasManualAmountEntry(true);
17617
+ } else {
17618
+ if (isFiatExchangeRatesLoading) return;
17619
+ const fallbackUsdAmount = getConvertedPrefilledAmount("usd");
17620
+ setCurrency("usd");
17621
+ if (fallbackUsdAmount) {
17622
+ setAmount(fallbackUsdAmount);
17623
+ setHasManualAmountEntry(true);
17624
+ }
17625
+ }
17626
+ return;
17627
+ }
17628
+ if (hasManualAmountEntry && amount) {
17629
+ const convertedAmount = convertAmountBetweenCurrencies(
17630
+ amount,
17631
+ currentCurrency,
17632
+ nextCurrency
17633
+ );
17634
+ if (convertedAmount) {
17635
+ setCurrency(nextCurrency);
17636
+ setAmount(convertedAmount);
17637
+ }
17638
+ return;
17639
+ }
17640
+ setCurrency(nextCurrency);
17494
17641
  },
17495
17642
  themeClass
17496
17643
  }
@@ -17543,7 +17690,7 @@ function useCoinbaseLegalAgreements({
17543
17690
  publishableKey,
17544
17691
  enabled = true
17545
17692
  }) {
17546
- return (0, import_react_query5.useQuery)({
17693
+ return (0, import_react_query6.useQuery)({
17547
17694
  queryKey: ["unifold", "coinbaseLegalAgreements", publishableKey],
17548
17695
  queryFn: () => getCoinbaseLegalAgreements(publishableKey),
17549
17696
  enabled: enabled && !!publishableKey,
@@ -17561,7 +17708,7 @@ function useApplePayLimits({
17561
17708
  enabled = true
17562
17709
  }) {
17563
17710
  const phoneValid = US_E164_REGEX.test(phone);
17564
- return (0, import_react_query6.useQuery)({
17711
+ return (0, import_react_query7.useQuery)({
17565
17712
  queryKey: ["unifold", "applePayLimits", phone, publishableKey],
17566
17713
  queryFn: ({ signal }) => getCoinbaseApplePayLimits(phone, publishableKey, signal),
17567
17714
  enabled: enabled && phoneValid && !!publishableKey,
@@ -17661,7 +17808,7 @@ function useDefaultOnrampToken({
17661
17808
  isLoading,
17662
17809
  isError,
17663
17810
  error
17664
- } = (0, import_react_query7.useQuery)({
17811
+ } = (0, import_react_query8.useQuery)({
17665
17812
  queryKey: [
17666
17813
  "unifold",
17667
17814
  "defaultOnrampToken",
@@ -17735,7 +17882,7 @@ function parseCoinbasePostMessage(raw) {
17735
17882
  } : void 0
17736
17883
  };
17737
17884
  }
17738
- var BuyWithApplePay = React52.forwardRef(
17885
+ var BuyWithApplePay = React62.forwardRef(
17739
17886
  function BuyWithApplePay2({
17740
17887
  userId,
17741
17888
  publishableKey,
@@ -17894,7 +18041,7 @@ var BuyWithApplePay = React52.forwardRef(
17894
18041
  popupRef.current = null;
17895
18042
  };
17896
18043
  }, []);
17897
- React52.useImperativeHandle(
18044
+ React62.useImperativeHandle(
17898
18045
  ref,
17899
18046
  () => ({
17900
18047
  requestBack: () => {
@@ -19204,7 +19351,7 @@ function LegalDisclaimer({ legalAgreements, loading }) {
19204
19351
  children: [
19205
19352
  "By continuing, you agree to Coinbase's",
19206
19353
  " ",
19207
- agreements.map((a, idx, arr) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(React52.Fragment, { children: [
19354
+ agreements.map((a, idx, arr) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(React62.Fragment, { children: [
19208
19355
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
19209
19356
  "a",
19210
19357
  {
@@ -19620,7 +19767,7 @@ function useIsMobileViewport() {
19620
19767
  return isMobile;
19621
19768
  }
19622
19769
  function useCashAppLimits({ publishableKey, currency = "usd" }) {
19623
- return (0, import_react_query8.useQuery)({
19770
+ return (0, import_react_query9.useQuery)({
19624
19771
  queryKey: ["unifold", "cashAppLimits", currency, publishableKey],
19625
19772
  queryFn: () => getCashAppLimits(currency, publishableKey),
19626
19773
  enabled: !!publishableKey,
@@ -19633,6 +19780,7 @@ var POLL_INTERVAL_MS2 = 5e3;
19633
19780
  var FALLBACK_MIN_USD = 5;
19634
19781
  var SUGGESTED_AMOUNTS = [25, 50, 100];
19635
19782
  var t3 = i18n2.depositModal.cashApp;
19783
+ var sanitizePrefilledUsd = (value) => value?.replace(/[^0-9.]/g, "") ?? "";
19636
19784
  function PayWithCashApp({
19637
19785
  userId,
19638
19786
  publishableKey,
@@ -19647,6 +19795,7 @@ function PayWithCashApp({
19647
19795
  onEvent,
19648
19796
  onDepositSuccess,
19649
19797
  onDepositError,
19798
+ prefilledAmountUsd,
19650
19799
  wallets = []
19651
19800
  }) {
19652
19801
  const { colors: colors2, fonts, components } = useTheme();
@@ -19662,7 +19811,7 @@ function PayWithCashApp({
19662
19811
  const { data: limits, isLoading: limitsLoading } = useCashAppLimits({ publishableKey });
19663
19812
  const minUsd = limits?.minimum_amount ?? FALLBACK_MIN_USD;
19664
19813
  const maxUsd = limits?.maximum_amount ?? null;
19665
- const [amount, setAmount] = (0, import_react20.useState)("");
19814
+ const [amount, setAmount] = (0, import_react20.useState)(() => sanitizePrefilledUsd(prefilledAmountUsd));
19666
19815
  const [loading, setLoading] = (0, import_react20.useState)(false);
19667
19816
  const [session, setSession] = (0, import_react20.useState)(null);
19668
19817
  const [status, setStatus] = (0, import_react20.useState)("pending");
@@ -19785,6 +19934,13 @@ function PayWithCashApp({
19785
19934
  return () => clearInterval(interval);
19786
19935
  }, [session, view, status, publishableKey, onDepositSuccess, onDepositError]);
19787
19936
  const [softExpired, setSoftExpired] = (0, import_react20.useState)(false);
19937
+ (0, import_react20.useEffect)(() => {
19938
+ if (!prefilledAmountUsd) return;
19939
+ const cleaned = sanitizePrefilledUsd(prefilledAmountUsd);
19940
+ if (!cleaned) return;
19941
+ setAmount(cleaned);
19942
+ onAmountChange?.(cleaned);
19943
+ }, [prefilledAmountUsd, onAmountChange]);
19788
19944
  (0, import_react20.useEffect)(() => {
19789
19945
  if (!session?.expires_at || view !== "payment") return;
19790
19946
  const expiresMs = new Date(session.expires_at).getTime();
@@ -20139,7 +20295,7 @@ function useBankTransferProviders({
20139
20295
  countryCode
20140
20296
  }) {
20141
20297
  const normalizedCountry = countryCode?.toUpperCase();
20142
- const { data: providers, isLoading } = (0, import_react_query9.useQuery)({
20298
+ const { data: providers, isLoading } = (0, import_react_query10.useQuery)({
20143
20299
  queryKey: ["unifold", "bankTransferProviders", publishableKey, normalizedCountry ?? null],
20144
20300
  queryFn: () => getBankTransferProviders(publishableKey, { countryCode: normalizedCountry }),
20145
20301
  enabled,
@@ -20177,7 +20333,8 @@ function BankTransfer({
20177
20333
  assetCdnUrl,
20178
20334
  onDepositSuccess,
20179
20335
  onEvent,
20180
- onDepositError
20336
+ onDepositError,
20337
+ prefilledAmountUsd
20181
20338
  }) {
20182
20339
  const { colors: colors2, fonts, components } = useTheme();
20183
20340
  const [internalView, setInternalView] = (0, import_react23.useState)("providers");
@@ -20187,6 +20344,10 @@ function BankTransfer({
20187
20344
  const [requestBase, setRequestBase] = (0, import_react23.useState)(null);
20188
20345
  const [activeRequest, setActiveRequest] = (0, import_react23.useState)(null);
20189
20346
  const [amount, setAmount] = (0, import_react23.useState)("");
20347
+ const [fiatExchangeRates, setFiatExchangeRates] = (0, import_react23.useState)({
20348
+ usd: 1
20349
+ });
20350
+ const providerSelectionRequestIdRef = (0, import_react23.useRef)(0);
20190
20351
  const currentView = externalView ?? internalView;
20191
20352
  const setView = (v) => {
20192
20353
  setInternalView(v);
@@ -20236,7 +20397,38 @@ function BankTransfer({
20236
20397
  () => destinationTokenSymbol?.toUpperCase() ?? defaultToken?.destination_token_metadata?.symbol?.toUpperCase() ?? defaultToken?.destination_currency?.toUpperCase() ?? "USDC",
20237
20398
  [destinationTokenSymbol, defaultToken]
20238
20399
  );
20239
- const handleProviderClick = (provider) => {
20400
+ const resolvePrefilledSourceAmount = (0, import_react23.useCallback)(
20401
+ async (sourceCurrencyCode) => {
20402
+ const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
20403
+ if (!cleanedPrefilled) return "";
20404
+ const prefilledUsd = parseFloat(cleanedPrefilled);
20405
+ if (!Number.isFinite(prefilledUsd) || prefilledUsd <= 0) return "";
20406
+ const sourceCurrency2 = sourceCurrencyCode.toLowerCase();
20407
+ let rate = sourceCurrency2 === "usd" ? 1 : fiatExchangeRates[sourceCurrency2];
20408
+ if ((!rate || rate <= 0) && sourceCurrency2 !== "usd") {
20409
+ try {
20410
+ const response = await getFiatExchangeRates({}, publishableKey);
20411
+ if (response?.rates) {
20412
+ setFiatExchangeRates((prev) => ({
20413
+ ...prev,
20414
+ ...response.rates,
20415
+ usd: 1
20416
+ }));
20417
+ }
20418
+ const fetchedRate = response.rates?.[sourceCurrency2];
20419
+ if (Number.isFinite(fetchedRate) && fetchedRate > 0) {
20420
+ rate = fetchedRate;
20421
+ }
20422
+ } catch (error) {
20423
+ console.error("Error fetching fiat exchange rates for bank transfer:", error);
20424
+ }
20425
+ }
20426
+ if (!rate || rate <= 0) return sourceCurrency2 === "usd" ? cleanedPrefilled : "";
20427
+ return parseFloat((prefilledUsd * rate).toFixed(2)).toString();
20428
+ },
20429
+ [fiatExchangeRates, prefilledAmountUsd, publishableKey]
20430
+ );
20431
+ const handleProviderClick = async (provider) => {
20240
20432
  if (!provider.enabled) return;
20241
20433
  setSessionError(null);
20242
20434
  if (!defaultToken) {
@@ -20255,6 +20447,7 @@ function BankTransfer({
20255
20447
  });
20256
20448
  return;
20257
20449
  }
20450
+ const requestId = ++providerSelectionRequestIdRef.current;
20258
20451
  setRequestBase({
20259
20452
  service_provider: provider.service_provider,
20260
20453
  country_code: (userIpInfo?.alpha2 || "DE").toUpperCase(),
@@ -20268,7 +20461,10 @@ function BankTransfer({
20268
20461
  payment_method: provider.payment_methods[0]
20269
20462
  });
20270
20463
  setActiveProvider(provider);
20271
- setAmount("100");
20464
+ const convertedPrefilled = await resolvePrefilledSourceAmount(provider.source_currency);
20465
+ if (requestId !== providerSelectionRequestIdRef.current) return;
20466
+ const hasPrefilledAmount = !!prefilledAmountUsd?.replace(/[^0-9.]/g, "");
20467
+ setAmount(hasPrefilledAmount ? convertedPrefilled : "100");
20272
20468
  setView("amount");
20273
20469
  };
20274
20470
  const handleAmountChange = (value) => {
@@ -20366,7 +20562,7 @@ function BankTransfer({
20366
20562
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
20367
20563
  "button",
20368
20564
  {
20369
- onClick: () => handleProviderClick(provider),
20565
+ onClick: () => void handleProviderClick(provider),
20370
20566
  onMouseEnter: () => !disabled && setHoveredId(provider.service_provider),
20371
20567
  onMouseLeave: () => setHoveredId(null),
20372
20568
  disabled,
@@ -20935,9 +21131,9 @@ function TransferCryptoButton({
20935
21131
  featuredTokens
20936
21132
  }) {
20937
21133
  const { colors: colors2, fonts, components } = useTheme();
20938
- const [isHovered, setIsHovered] = React62.useState(false);
20939
- const [isTouchDevice, setIsTouchDevice] = React62.useState(false);
20940
- React62.useEffect(() => {
21134
+ const [isHovered, setIsHovered] = React72.useState(false);
21135
+ const [isTouchDevice, setIsTouchDevice] = React72.useState(false);
21136
+ React72.useEffect(() => {
20941
21137
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
20942
21138
  }, []);
20943
21139
  const sortedTokens = featuredTokens ? [...featuredTokens].sort((a, b) => a.position - b.position) : [];
@@ -21017,9 +21213,9 @@ function DepositWithCardButton({
21017
21213
  paymentNetworks
21018
21214
  }) {
21019
21215
  const { colors: colors2, fonts, components } = useTheme();
21020
- const [isHovered, setIsHovered] = React72.useState(false);
21021
- const [isTouchDevice, setIsTouchDevice] = React72.useState(false);
21022
- React72.useEffect(() => {
21216
+ const [isHovered, setIsHovered] = React82.useState(false);
21217
+ const [isTouchDevice, setIsTouchDevice] = React82.useState(false);
21218
+ React82.useEffect(() => {
21023
21219
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21024
21220
  }, []);
21025
21221
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
@@ -21098,9 +21294,9 @@ function PayWithExchangeButton({
21098
21294
  loading = false
21099
21295
  }) {
21100
21296
  const { colors: colors2, fonts, components } = useTheme();
21101
- const [isHovered, setIsHovered] = React82.useState(false);
21102
- const [isTouchDevice, setIsTouchDevice] = React82.useState(false);
21103
- React82.useEffect(() => {
21297
+ const [isHovered, setIsHovered] = React92.useState(false);
21298
+ const [isTouchDevice, setIsTouchDevice] = React92.useState(false);
21299
+ React92.useEffect(() => {
21104
21300
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21105
21301
  }, []);
21106
21302
  if (loading) {
@@ -21202,11 +21398,11 @@ var buttonVariants = cva(
21202
21398
  }
21203
21399
  }
21204
21400
  );
21205
- var Button = React92.forwardRef(
21401
+ var Button = React102.forwardRef(
21206
21402
  ({ className, variant, size: size4, asChild = false, style, ...props }, ref) => {
21207
21403
  const Comp = asChild ? Slot2 : "button";
21208
21404
  const { components, fonts } = useTheme();
21209
- const themeStyle = React92.useMemo(() => {
21405
+ const themeStyle = React102.useMemo(() => {
21210
21406
  const baseStyle = { ...style };
21211
21407
  if (variant === "default" || !variant) {
21212
21408
  baseStyle.backgroundColor = components.button.primaryBackground;
@@ -21241,9 +21437,9 @@ function ConnectExchangeButton({
21241
21437
  connectedExchange
21242
21438
  }) {
21243
21439
  const { colors: colors2, fonts, components } = useTheme();
21244
- const [isHovered, setIsHovered] = React102.useState(false);
21245
- const [isTouchDevice, setIsTouchDevice] = React102.useState(false);
21246
- React102.useEffect(() => {
21440
+ const [isHovered, setIsHovered] = React112.useState(false);
21441
+ const [isTouchDevice, setIsTouchDevice] = React112.useState(false);
21442
+ React112.useEffect(() => {
21247
21443
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21248
21444
  }, []);
21249
21445
  const isConnected = connectedExchange != null;
@@ -21388,9 +21584,9 @@ function DepositTrackerButton({
21388
21584
  badge
21389
21585
  }) {
21390
21586
  const { colors: colors2, fonts, components } = useTheme();
21391
- const [isHovered, setIsHovered] = React112.useState(false);
21392
- const [isTouchDevice, setIsTouchDevice] = React112.useState(false);
21393
- React112.useEffect(() => {
21587
+ const [isHovered, setIsHovered] = React122.useState(false);
21588
+ const [isTouchDevice, setIsTouchDevice] = React122.useState(false);
21589
+ React122.useEffect(() => {
21394
21590
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21395
21591
  }, []);
21396
21592
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
@@ -21461,9 +21657,9 @@ function DepositTrackerButton({
21461
21657
  }
21462
21658
  function CashAppButton({ onClick, title, subtitle, iconUrl }) {
21463
21659
  const { colors: colors2, fonts, components } = useTheme();
21464
- const [isHovered, setIsHovered] = React122.useState(false);
21465
- const [isTouchDevice, setIsTouchDevice] = React122.useState(false);
21466
- React122.useEffect(() => {
21660
+ const [isHovered, setIsHovered] = React132.useState(false);
21661
+ const [isTouchDevice, setIsTouchDevice] = React132.useState(false);
21662
+ React132.useEffect(() => {
21467
21663
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21468
21664
  }, []);
21469
21665
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
@@ -21547,9 +21743,9 @@ function AppleLogo({ className, style }) {
21547
21743
  }
21548
21744
  function ApplePayButton({ onClick, title, subtitle }) {
21549
21745
  const { colors: colors2, fonts, components } = useTheme();
21550
- const [isHovered, setIsHovered] = React132.useState(false);
21551
- const [isTouchDevice, setIsTouchDevice] = React132.useState(false);
21552
- React132.useEffect(() => {
21746
+ const [isHovered, setIsHovered] = React142.useState(false);
21747
+ const [isTouchDevice, setIsTouchDevice] = React142.useState(false);
21748
+ React142.useEffect(() => {
21553
21749
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21554
21750
  }, []);
21555
21751
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
@@ -21611,9 +21807,9 @@ function BankTransferButton({
21611
21807
  comingSoon = false
21612
21808
  }) {
21613
21809
  const { colors: colors2, fonts, components } = useTheme();
21614
- const [isHovered, setIsHovered] = React142.useState(false);
21615
- const [isTouchDevice, setIsTouchDevice] = React142.useState(false);
21616
- React142.useEffect(() => {
21810
+ const [isHovered, setIsHovered] = React152.useState(false);
21811
+ const [isTouchDevice, setIsTouchDevice] = React152.useState(false);
21812
+ React152.useEffect(() => {
21617
21813
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21618
21814
  }, []);
21619
21815
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
@@ -21862,18 +22058,18 @@ async function detectConnectedBrowserWallet(chainType) {
21862
22058
  }
21863
22059
  function useDetectedBrowserWallet(opts = {}) {
21864
22060
  const { chainType, enabled = true, onDisconnect } = opts;
21865
- const [wallet, setWallet] = React152.useState(null);
21866
- const [isLoading, setIsLoading] = React152.useState(enabled);
21867
- const [eip6963ProviderCount, setEip6963ProviderCount] = React152.useState(0);
21868
- const onDisconnectRef = React152.useRef(onDisconnect);
22061
+ const [wallet, setWallet] = React162.useState(null);
22062
+ const [isLoading, setIsLoading] = React162.useState(enabled);
22063
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React162.useState(0);
22064
+ const onDisconnectRef = React162.useRef(onDisconnect);
21869
22065
  onDisconnectRef.current = onDisconnect;
21870
- React152.useEffect(() => {
22066
+ React162.useEffect(() => {
21871
22067
  const store = getEip6963Store();
21872
22068
  if (!store) return;
21873
22069
  setEip6963ProviderCount(store.getProviders().length);
21874
22070
  return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
21875
22071
  }, []);
21876
- React152.useEffect(() => {
22072
+ React162.useEffect(() => {
21877
22073
  if (!enabled) {
21878
22074
  setWallet(null);
21879
22075
  setIsLoading(false);
@@ -22014,7 +22210,7 @@ async function disconnectInjectedBrowserWallet(wallet) {
22014
22210
  );
22015
22211
  }
22016
22212
  function MetamaskIcon({ size: size4 = 24, className, variant = "color" }) {
22017
- const id = React162.useId();
22213
+ const id = React172.useId();
22018
22214
  if (variant === "light" || variant === "dark") {
22019
22215
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
22020
22216
  "svg",
@@ -22135,7 +22331,7 @@ function MetamaskIcon({ size: size4 = 24, className, variant = "color" }) {
22135
22331
  );
22136
22332
  }
22137
22333
  function PhantomIcon({ size: size4 = 24, className, variant = "color" }) {
22138
- const id = React172.useId();
22334
+ const id = React182.useId();
22139
22335
  if (variant === "light") {
22140
22336
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
22141
22337
  "svg",
@@ -22202,7 +22398,7 @@ function PhantomIcon({ size: size4 = 24, className, variant = "color" }) {
22202
22398
  );
22203
22399
  }
22204
22400
  function CoinbaseIcon({ size: size4 = 24, className, variant = "color" }) {
22205
- const id = React182.useId();
22401
+ const id = React192.useId();
22206
22402
  if (variant === "light") {
22207
22403
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
22208
22404
  "svg",
@@ -22282,7 +22478,7 @@ function CoinbaseIcon({ size: size4 = 24, className, variant = "color" }) {
22282
22478
  );
22283
22479
  }
22284
22480
  function RabbyIcon({ size: size4 = 24, className, variant = "color" }) {
22285
- const id = React192.useId();
22481
+ const id = React202.useId();
22286
22482
  if (variant === "light") {
22287
22483
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
22288
22484
  "svg",
@@ -22629,7 +22825,7 @@ function RabbyIcon({ size: size4 = 24, className, variant = "color" }) {
22629
22825
  );
22630
22826
  }
22631
22827
  function RainbowIcon({ size: size4 = 24, className, variant = "color" }) {
22632
- const id = React202.useId();
22828
+ const id = React212.useId();
22633
22829
  if (variant === "light") {
22634
22830
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
22635
22831
  "svg",
@@ -23043,7 +23239,7 @@ function RainbowIcon({ size: size4 = 24, className, variant = "color" }) {
23043
23239
  );
23044
23240
  }
23045
23241
  function TrustIcon({ size: size4 = 24, className, variant = "color" }) {
23046
- const id = React212.useId();
23242
+ const id = React222.useId();
23047
23243
  if (variant === "light") {
23048
23244
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
23049
23245
  "svg",
@@ -23126,7 +23322,7 @@ function TrustIcon({ size: size4 = 24, className, variant = "color" }) {
23126
23322
  );
23127
23323
  }
23128
23324
  function OkxIcon({ size: size4 = 24, className, variant = "color" }) {
23129
- const id = React222.useId();
23325
+ const id = React232.useId();
23130
23326
  if (variant === "light") {
23131
23327
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
23132
23328
  "svg",
@@ -23181,7 +23377,7 @@ function OkxIcon({ size: size4 = 24, className, variant = "color" }) {
23181
23377
  );
23182
23378
  }
23183
23379
  function GlowIcon({ size: size4 = 24, className, variant = "color" }) {
23184
- const id = React232.useId();
23380
+ const id = React242.useId();
23185
23381
  if (variant === "light") {
23186
23382
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
23187
23383
  "svg",
@@ -23282,7 +23478,7 @@ function GlowIcon({ size: size4 = 24, className, variant = "color" }) {
23282
23478
  );
23283
23479
  }
23284
23480
  function BackpackIcon({ size: size4 = 24, className, variant = "color" }) {
23285
- const id = React242.useId();
23481
+ const id = React252.useId();
23286
23482
  if (variant === "light") {
23287
23483
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
23288
23484
  "svg",
@@ -23355,7 +23551,7 @@ function BackpackIcon({ size: size4 = 24, className, variant = "color" }) {
23355
23551
  );
23356
23552
  }
23357
23553
  function SolflareIcon({ size: size4 = 24, className, variant = "color" }) {
23358
- const id = React252.useId();
23554
+ const id = React262.useId();
23359
23555
  if (variant === "light") {
23360
23556
  return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
23361
23557
  "svg",
@@ -23422,7 +23618,7 @@ function SolflareIcon({ size: size4 = 24, className, variant = "color" }) {
23422
23618
  );
23423
23619
  }
23424
23620
  function EthereumIcon({ size: size4 = 24, className, variant = "color" }) {
23425
- const id = React262.useId();
23621
+ const id = React272.useId();
23426
23622
  if (variant === "light") {
23427
23623
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
23428
23624
  "svg",
@@ -23546,7 +23742,7 @@ function EthereumIcon({ size: size4 = 24, className, variant = "color" }) {
23546
23742
  );
23547
23743
  }
23548
23744
  function SolanaIcon({ size: size4 = 24, className, variant = "color" }) {
23549
- const id = React272.useId();
23745
+ const id = React282.useId();
23550
23746
  if (variant === "light") {
23551
23747
  return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
23552
23748
  "svg",
@@ -23791,19 +23987,19 @@ function BrowserWalletButton({
23791
23987
  subtitle = i18n2.depositModal.browserWallet.subtitle
23792
23988
  }) {
23793
23989
  const { colors: colors2, fonts, components } = useTheme();
23794
- const [isHovered, setIsHovered] = React282.useState(false);
23795
- const [isTouchDevice, setIsTouchDevice] = React282.useState(false);
23990
+ const [isHovered, setIsHovered] = React292.useState(false);
23991
+ const [isTouchDevice, setIsTouchDevice] = React292.useState(false);
23796
23992
  const { wallet, isLoading, setWallet } = useDetectedBrowserWallet({ chainType, onDisconnect });
23797
- const [isConnecting, setIsConnecting] = React282.useState(false);
23798
- const [balanceText, setBalanceText] = React282.useState(null);
23799
- const [isLoadingBalance, setIsLoadingBalance] = React282.useState(false);
23800
- const [isDisconnecting, setIsDisconnecting] = React282.useState(false);
23801
- const onDisconnectRef = React282.useRef(onDisconnect);
23993
+ const [isConnecting, setIsConnecting] = React292.useState(false);
23994
+ const [balanceText, setBalanceText] = React292.useState(null);
23995
+ const [isLoadingBalance, setIsLoadingBalance] = React292.useState(false);
23996
+ const [isDisconnecting, setIsDisconnecting] = React292.useState(false);
23997
+ const onDisconnectRef = React292.useRef(onDisconnect);
23802
23998
  onDisconnectRef.current = onDisconnect;
23803
- React282.useEffect(() => {
23999
+ React292.useEffect(() => {
23804
24000
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
23805
24001
  }, []);
23806
- React282.useEffect(() => {
24002
+ React292.useEffect(() => {
23807
24003
  if (!wallet || !publishableKey) {
23808
24004
  setBalanceText(null);
23809
24005
  return;
@@ -23930,7 +24126,7 @@ function BrowserWalletButton({
23930
24126
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
23931
24127
  };
23932
24128
  const sortedWallets = featuredWallets ? [...featuredWallets].sort((a, b) => a.position - b.position) : [];
23933
- const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React282.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
24129
+ const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React292.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
23934
24130
  size: 36,
23935
24131
  className: "uf-rounded-lg",
23936
24132
  variant: "color"
@@ -24081,9 +24277,9 @@ function StripeLinkButton({
24081
24277
  iconUrl
24082
24278
  }) {
24083
24279
  const { colors: colors2, fonts, components } = useTheme();
24084
- const [isHovered, setIsHovered] = React292.useState(false);
24085
- const [isTouchDevice, setIsTouchDevice] = React292.useState(false);
24086
- React292.useEffect(() => {
24280
+ const [isHovered, setIsHovered] = React302.useState(false);
24281
+ const [isTouchDevice, setIsTouchDevice] = React302.useState(false);
24282
+ React302.useEffect(() => {
24087
24283
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
24088
24284
  }, []);
24089
24285
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
@@ -24569,6 +24765,8 @@ function PayWithStripeLink({
24569
24765
  destinationChainType,
24570
24766
  destinationChainId,
24571
24767
  destinationTokenAddress,
24768
+ countryCode,
24769
+ subdivisionCode,
24572
24770
  wallets: externalWallets,
24573
24771
  email: emailProp,
24574
24772
  iconUrl,
@@ -24963,7 +25161,9 @@ function PayWithStripeLink({
24963
25161
  {
24964
25162
  tokenAddress: destinationTokenAddress,
24965
25163
  chainId: destinationChainId,
24966
- chainType: destinationChainType
25164
+ chainType: destinationChainType,
25165
+ countryCode,
25166
+ subdivisionCode
24967
25167
  },
24968
25168
  publishableKey
24969
25169
  ).then((token) => {
@@ -24982,7 +25182,14 @@ function PayWithStripeLink({
24982
25182
  return () => {
24983
25183
  cancelled = true;
24984
25184
  };
24985
- }, [publishableKey, destinationTokenAddress, destinationChainId, destinationChainType]);
25185
+ }, [
25186
+ publishableKey,
25187
+ destinationTokenAddress,
25188
+ destinationChainId,
25189
+ destinationChainType,
25190
+ countryCode,
25191
+ subdivisionCode
25192
+ ]);
24986
25193
  const destinationCurrency = stripeDestCurrency;
24987
25194
  const authInnerRef = (0, import_react24.useRef)(null);
24988
25195
  const paymentInnerRef = (0, import_react24.useRef)(null);
@@ -27840,7 +28047,7 @@ function useProjectConfig({
27840
28047
  data: projectConfig,
27841
28048
  isLoading,
27842
28049
  error
27843
- } = (0, import_react_query10.useQuery)({
28050
+ } = (0, import_react_query11.useQuery)({
27844
28051
  // Country is part of the key so a region change refetches the region-aware
27845
28052
  // config. Omitted when undefined so callers that don't pass a country keep
27846
28053
  // sharing the base cache entry.
@@ -27850,7 +28057,7 @@ function useProjectConfig({
27850
28057
  // Keep the previous (e.g. no-country) config visible while the region-aware
27851
28058
  // config refetches after the country resolves, so unrelated config-driven
27852
28059
  // UI doesn't flash back to defaults.
27853
- placeholderData: import_react_query10.keepPreviousData,
28060
+ placeholderData: import_react_query11.keepPreviousData,
27854
28061
  staleTime: 1e3 * 60 * 30,
27855
28062
  refetchOnMount: true,
27856
28063
  refetchOnWindowFocus: true
@@ -27868,7 +28075,7 @@ function useSupportedDepositTokens(publishableKey, options) {
27868
28075
  ...options?.product_type ? { product_type: options.product_type } : {}
27869
28076
  };
27870
28077
  const hasFilteredOptions = Object.keys(filteredOptions).length > 0;
27871
- return (0, import_react_query11.useQuery)({
28078
+ return (0, import_react_query12.useQuery)({
27872
28079
  queryKey: [
27873
28080
  "unifold",
27874
28081
  "supportedDepositTokens",
@@ -27892,7 +28099,7 @@ function useIntegrationTransferDefaultToken({
27892
28099
  publishableKey,
27893
28100
  enabled = true
27894
28101
  }) {
27895
- return (0, import_react_query12.useQuery)({
28102
+ return (0, import_react_query13.useQuery)({
27896
28103
  queryKey: [
27897
28104
  "unifold",
27898
28105
  "integrationTransferDefaultToken",
@@ -27958,7 +28165,8 @@ function CoinbaseConnect({
27958
28165
  defaultSourceChainType,
27959
28166
  defaultSourceChainId,
27960
28167
  defaultSourceTokenAddress,
27961
- defaultSourceSymbol
28168
+ defaultSourceSymbol,
28169
+ prefilledAmountUsd
27962
28170
  }) {
27963
28171
  const { colors: colors2, fonts, components } = useTheme();
27964
28172
  const { projectConfig } = useProjectConfig({ publishableKey });
@@ -28281,7 +28489,8 @@ function CoinbaseConnect({
28281
28489
  };
28282
28490
  const handleSelectAsset = (asset) => {
28283
28491
  setSelectedAsset(asset);
28284
- setSendAmount("");
28492
+ const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
28493
+ setSendAmount(cleanedPrefilled);
28285
28494
  transitionTo("enter_amount");
28286
28495
  };
28287
28496
  const handleCreateTransfer = async () => {
@@ -29869,7 +30078,7 @@ function useExchanges({
29869
30078
  publishableKey,
29870
30079
  enabled = true
29871
30080
  }) {
29872
- const { data: exchanges = [], isLoading } = (0, import_react_query13.useQuery)({
30081
+ const { data: exchanges = [], isLoading } = (0, import_react_query14.useQuery)({
29873
30082
  queryKey: ["unifold", "exchanges", publishableKey],
29874
30083
  queryFn: () => getExchanges(void 0, publishableKey).then((res) => res.data),
29875
30084
  enabled,
@@ -29883,7 +30092,7 @@ function useApplePayProviders({
29883
30092
  publishableKey,
29884
30093
  enabled = true
29885
30094
  }) {
29886
- const { data: providers, isLoading } = (0, import_react_query14.useQuery)({
30095
+ const { data: providers, isLoading } = (0, import_react_query15.useQuery)({
29887
30096
  queryKey: ["unifold", "applePayProviders", publishableKey],
29888
30097
  queryFn: () => getApplePayProviders(publishableKey),
29889
30098
  enabled,
@@ -29943,7 +30152,7 @@ function useAddressValidation({
29943
30152
  refetchOnMount = false
29944
30153
  }) {
29945
30154
  const shouldValidate = enabled && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
29946
- const { data, isLoading, error } = (0, import_react_query15.useQuery)({
30155
+ const { data, isLoading, error } = (0, import_react_query16.useQuery)({
29947
30156
  queryKey: [
29948
30157
  "unifold",
29949
30158
  "addressValidation",
@@ -29992,7 +30201,7 @@ function ThemeStyleInjector({
29992
30201
  className
29993
30202
  }) {
29994
30203
  const { colors: colors2, fonts, mode } = useTheme();
29995
- const cssVars = React312.useMemo(() => {
30204
+ const cssVars = React322.useMemo(() => {
29996
30205
  const hexToHSL = (hex) => {
29997
30206
  hex = hex.replace("#", "");
29998
30207
  const r2 = parseInt(hex.slice(0, 2), 16) / 255;
@@ -30052,7 +30261,7 @@ function ThemeStyleInjector({
30052
30261
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
30053
30262
  };
30054
30263
  }, [colors2, fonts.regular]);
30055
- React312.useEffect(() => {
30264
+ React322.useEffect(() => {
30056
30265
  if (typeof document === "undefined") return;
30057
30266
  if (fonts.regular) {
30058
30267
  document.documentElement.style.setProperty("--uf-font-family", fonts.regular);
@@ -31197,14 +31406,14 @@ function useCopyAddress() {
31197
31406
  return { copied, handleCopy };
31198
31407
  }
31199
31408
  var TooltipProvider2 = Provider;
31200
- var TooltipContext = React322.createContext({
31409
+ var TooltipContext = React332.createContext({
31201
31410
  open: false,
31202
31411
  onOpenChange: () => {
31203
31412
  }
31204
31413
  });
31205
- var TooltipTrigger2 = React322.forwardRef(({ onClick, ...props }, ref) => {
31206
- const { open, onOpenChange } = React322.useContext(TooltipContext);
31207
- const handleClick = React322.useCallback(
31414
+ var TooltipTrigger2 = React332.forwardRef(({ onClick, ...props }, ref) => {
31415
+ const { open, onOpenChange } = React332.useContext(TooltipContext);
31416
+ const handleClick = React332.useCallback(
31208
31417
  (e) => {
31209
31418
  onOpenChange(!open);
31210
31419
  onClick?.(e);
@@ -31214,7 +31423,7 @@ var TooltipTrigger2 = React322.forwardRef(({ onClick, ...props }, ref) => {
31214
31423
  return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Trigger, { ref, onClick: handleClick, ...props });
31215
31424
  });
31216
31425
  TooltipTrigger2.displayName = Trigger.displayName;
31217
- var TooltipContent2 = React322.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
31426
+ var TooltipContent2 = React332.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
31218
31427
  const { themeClass, colors: colors2 } = useTheme();
31219
31428
  return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
31220
31429
  Content22,
@@ -31245,7 +31454,7 @@ function useHypercoreActivation(params) {
31245
31454
  const recipient = recipientAddress?.trim() ?? "";
31246
31455
  const source = sourceAddress?.trim() ?? "";
31247
31456
  const hasAddresses = !!recipient && !!source;
31248
- const { data, isLoading } = (0, import_react_query16.useQuery)({
31457
+ const { data, isLoading } = (0, import_react_query17.useQuery)({
31249
31458
  queryKey: ["unifold", "hypercoreActivation", source, recipient, publishableKey],
31250
31459
  queryFn: () => checkHypercoreActivation(
31251
31460
  {
@@ -31324,6 +31533,7 @@ function TransferCryptoSingleInput({
31324
31533
  onDepositError,
31325
31534
  wallets: externalWallets,
31326
31535
  onSourceTokenChange,
31536
+ prefilledAmountUsd,
31327
31537
  checkoutQuote,
31328
31538
  isCheckoutQuoteLoading = false,
31329
31539
  persistCheckingIndicator = false,
@@ -31467,6 +31677,22 @@ function TransferCryptoSingleInput({
31467
31677
  const maxSlippage = currentChainFromBackend?.max_slippage_percent ?? 0.25;
31468
31678
  const processingTime = currentChainFromBackend?.estimated_processing_time ?? null;
31469
31679
  const minDepositUsd = currentChainFromBackend?.minimum_deposit_amount_usd ?? 3;
31680
+ const parsedPrefilledUsd = (0, import_react27.useMemo)(() => {
31681
+ const value = parseFloat(prefilledAmountUsd ?? "");
31682
+ return Number.isFinite(value) && value > 0 ? value : null;
31683
+ }, [prefilledAmountUsd]);
31684
+ const effectivePrefilledUsd = (0, import_react27.useMemo)(() => {
31685
+ if (parsedPrefilledUsd === null) return null;
31686
+ return Math.max(parsedPrefilledUsd, minDepositUsd);
31687
+ }, [parsedPrefilledUsd, minDepositUsd]);
31688
+ const prefillDisplay = (0, import_react27.useMemo)(() => {
31689
+ if (effectivePrefilledUsd === null) return null;
31690
+ const usdLabel = `$${effectivePrefilledUsd.toFixed(2)}`;
31691
+ if (selectedToken?.is_stablecoin) {
31692
+ return `${effectivePrefilledUsd.toFixed(2)} ${selectedToken.symbol} (${usdLabel})`;
31693
+ }
31694
+ return `${usdLabel} USD`;
31695
+ }, [effectivePrefilledUsd, selectedToken]);
31470
31696
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TooltipProvider2, { delayDuration: 0, skipDelayDuration: 0, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
31471
31697
  "div",
31472
31698
  {
@@ -31593,7 +31819,7 @@ function TransferCryptoSingleInput({
31593
31819
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { children: "Retrying automatically every 5 seconds..." })
31594
31820
  ] })
31595
31821
  ] }),
31596
- (checkoutQuote || isCheckoutQuoteLoading) && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
31822
+ (checkoutQuote || isCheckoutQuoteLoading || prefillDisplay) && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
31597
31823
  "div",
31598
31824
  {
31599
31825
  className: "uf-rounded-xl uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
@@ -31637,6 +31863,13 @@ function TransferCryptoSingleInput({
31637
31863
  )
31638
31864
  ]
31639
31865
  }
31866
+ ) : prefillDisplay ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31867
+ "span",
31868
+ {
31869
+ className: "uf-text-sm uf-font-semibold",
31870
+ style: { color: components.card.titleColor, fontFamily: fonts.semibold },
31871
+ children: prefillDisplay
31872
+ }
31640
31873
  ) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31641
31874
  "div",
31642
31875
  {
@@ -31966,7 +32199,7 @@ function TransferCryptoSingleInput({
31966
32199
  }
31967
32200
  var Select2 = Root23;
31968
32201
  var SelectValue2 = Value;
31969
- var SelectTrigger2 = React332.forwardRef(({ className, style, children, ...props }, ref) => {
32202
+ var SelectTrigger2 = React342.forwardRef(({ className, style, children, ...props }, ref) => {
31970
32203
  const { components } = useTheme();
31971
32204
  return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
31972
32205
  Trigger2,
@@ -31990,7 +32223,7 @@ var SelectTrigger2 = React332.forwardRef(({ className, style, children, ...props
31990
32223
  );
31991
32224
  });
31992
32225
  SelectTrigger2.displayName = Trigger2.displayName;
31993
- var SelectScrollUpButton2 = React332.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32226
+ var SelectScrollUpButton2 = React342.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
31994
32227
  ScrollUpButton,
31995
32228
  {
31996
32229
  ref,
@@ -32000,7 +32233,7 @@ var SelectScrollUpButton2 = React332.forwardRef(({ className, ...props }, ref) =
32000
32233
  }
32001
32234
  ));
32002
32235
  SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
32003
- var SelectScrollDownButton2 = React332.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32236
+ var SelectScrollDownButton2 = React342.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32004
32237
  ScrollDownButton,
32005
32238
  {
32006
32239
  ref,
@@ -32010,7 +32243,7 @@ var SelectScrollDownButton2 = React332.forwardRef(({ className, ...props }, ref)
32010
32243
  }
32011
32244
  ));
32012
32245
  SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
32013
- var SelectContent2 = React332.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
32246
+ var SelectContent2 = React342.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
32014
32247
  const { themeClass, colors: colors2, components } = useTheme();
32015
32248
  return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
32016
32249
  Content23,
@@ -32048,7 +32281,7 @@ var SelectContent2 = React332.forwardRef(({ className, style, children, position
32048
32281
  ) });
32049
32282
  });
32050
32283
  SelectContent2.displayName = Content23.displayName;
32051
- var SelectLabel2 = React332.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32284
+ var SelectLabel2 = React342.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32052
32285
  Label,
32053
32286
  {
32054
32287
  ref,
@@ -32057,7 +32290,7 @@ var SelectLabel2 = React332.forwardRef(({ className, ...props }, ref) => /* @__P
32057
32290
  }
32058
32291
  ));
32059
32292
  SelectLabel2.displayName = Label.displayName;
32060
- var SelectItem2 = React332.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
32293
+ var SelectItem2 = React342.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
32061
32294
  Item,
32062
32295
  {
32063
32296
  ref,
@@ -32073,7 +32306,7 @@ var SelectItem2 = React332.forwardRef(({ className, children, ...props }, ref) =
32073
32306
  }
32074
32307
  ));
32075
32308
  SelectItem2.displayName = Item.displayName;
32076
- var SelectSeparator2 = React332.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32309
+ var SelectSeparator2 = React342.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32077
32310
  Separator,
32078
32311
  {
32079
32312
  ref,
@@ -32101,6 +32334,7 @@ function TransferCryptoDoubleInput({
32101
32334
  defaultSourceChainId,
32102
32335
  defaultSourceTokenAddress,
32103
32336
  defaultSourceSymbol,
32337
+ prefilledAmountUsd,
32104
32338
  depositConfirmationMode = "auto_ui",
32105
32339
  onExecutionsChange,
32106
32340
  onDepositSuccess,
@@ -32225,6 +32459,22 @@ function TransferCryptoDoubleInput({
32225
32459
  const maxSlippage = currentChainFromBackend?.max_slippage_percent ?? 0.25;
32226
32460
  const processingTime = currentChainFromBackend?.estimated_processing_time ?? null;
32227
32461
  const minDepositUsd = currentChainFromBackend?.minimum_deposit_amount_usd ?? 3;
32462
+ const parsedPrefilledUsd = (0, import_react32.useMemo)(() => {
32463
+ const value = parseFloat(prefilledAmountUsd ?? "");
32464
+ return Number.isFinite(value) && value > 0 ? value : null;
32465
+ }, [prefilledAmountUsd]);
32466
+ const effectivePrefilledUsd = (0, import_react32.useMemo)(() => {
32467
+ if (parsedPrefilledUsd === null) return null;
32468
+ return Math.max(parsedPrefilledUsd, minDepositUsd);
32469
+ }, [parsedPrefilledUsd, minDepositUsd]);
32470
+ const prefillDisplay = (0, import_react32.useMemo)(() => {
32471
+ if (effectivePrefilledUsd === null) return null;
32472
+ const usdLabel = `$${effectivePrefilledUsd.toFixed(2)}`;
32473
+ if (selectedToken?.is_stablecoin) {
32474
+ return `${effectivePrefilledUsd.toFixed(2)} ${selectedToken.symbol} (${usdLabel})`;
32475
+ }
32476
+ return `${usdLabel} USD`;
32477
+ }, [effectivePrefilledUsd, selectedToken]);
32228
32478
  const renderTokenItem = (tokenData) => {
32229
32479
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
32230
32480
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
@@ -32405,6 +32655,35 @@ function TransferCryptoDoubleInput({
32405
32655
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { children: "Retrying automatically every 5 seconds..." })
32406
32656
  ] })
32407
32657
  ] }),
32658
+ prefillDisplay && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
32659
+ "div",
32660
+ {
32661
+ className: "uf-rounded-xl uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
32662
+ style: {
32663
+ backgroundColor: components.card.backgroundColor,
32664
+ border: `${components.card.borderWidth}px solid ${components.card.borderColor}`,
32665
+ borderRadius: components.card.borderRadius
32666
+ },
32667
+ children: [
32668
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
32669
+ "span",
32670
+ {
32671
+ className: "uf-text-xs",
32672
+ style: { color: components.card.subtitleColor, fontFamily: fonts.regular },
32673
+ children: "You send"
32674
+ }
32675
+ ),
32676
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
32677
+ "span",
32678
+ {
32679
+ className: "uf-text-sm uf-font-semibold",
32680
+ style: { color: components.card.titleColor, fontFamily: fonts.semibold },
32681
+ children: prefillDisplay
32682
+ }
32683
+ )
32684
+ ]
32685
+ }
32686
+ ),
32408
32687
  /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-pt-2", children: [
32409
32688
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
32410
32689
  "div",
@@ -32743,7 +33022,7 @@ function useDepositQuote(params) {
32743
33022
  ...adjustForSlippage ? { adjust_for_slippage: true } : {},
32744
33023
  ...stablecoinParity ? { stablecoin_parity: true } : {}
32745
33024
  };
32746
- return (0, import_react_query17.useQuery)({
33025
+ return (0, import_react_query18.useQuery)({
32747
33026
  queryKey: [
32748
33027
  "unifold",
32749
33028
  "depositQuote",
@@ -32773,7 +33052,7 @@ function useExternalWallets({
32773
33052
  publishableKey,
32774
33053
  enabled = true
32775
33054
  }) {
32776
- const { data: wallets = [], isLoading } = (0, import_react_query18.useQuery)({
33055
+ const { data: wallets = [], isLoading } = (0, import_react_query19.useQuery)({
32777
33056
  queryKey: ["unifold", "external-wallets", publishableKey],
32778
33057
  queryFn: () => getExternalWallets(publishableKey).then((res) => res.data),
32779
33058
  enabled: enabled && !!publishableKey,
@@ -33992,7 +34271,7 @@ function WalletConnect({
33992
34271
  amountQuickSelect = "percentage",
33993
34272
  onWalletDisconnect,
33994
34273
  onWalletConnected,
33995
- prefillAmountUsd,
34274
+ prefilledAmountUsd,
33996
34275
  checkoutAmountUsd,
33997
34276
  checkoutReceivedUsd,
33998
34277
  onNewDeposit,
@@ -34014,28 +34293,28 @@ function WalletConnect({
34014
34293
  onExecutionsChange
34015
34294
  }) {
34016
34295
  const { colors: colors2, fonts, components, mode } = useTheme();
34017
- const walletProvidedAtMount = React342.useRef(!!initialWalletInfo && !!initialDepositWallet);
34018
- const [activeWalletInfo, setActiveWalletInfo] = React342.useState(
34296
+ const walletProvidedAtMount = React352.useRef(!!initialWalletInfo && !!initialDepositWallet);
34297
+ const [activeWalletInfo, setActiveWalletInfo] = React352.useState(
34019
34298
  initialWalletInfo ?? null
34020
34299
  );
34021
- const [activeDepositWallet, setActiveDepositWallet] = React342.useState(
34300
+ const [activeDepositWallet, setActiveDepositWallet] = React352.useState(
34022
34301
  initialDepositWallet ?? null
34023
34302
  );
34024
34303
  const initialView = initialWalletInfo && initialDepositWallet ? "select_token" : "select_wallet";
34025
- const [view, setView] = React342.useState(initialView);
34026
- const [isTransitioning, setIsTransitioning] = React342.useState(false);
34027
- const viewRef = React342.useRef(initialView);
34304
+ const [view, setView] = React352.useState(initialView);
34305
+ const [isTransitioning, setIsTransitioning] = React352.useState(false);
34306
+ const viewRef = React352.useRef(initialView);
34028
34307
  const standalone = !canGoBack && !walletProvidedAtMount.current;
34029
34308
  const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({
34030
34309
  enabled: standalone
34031
34310
  });
34032
- const [autoResolved, setAutoResolved] = React342.useState(false);
34033
- const [selectedWalletDef, setSelectedWalletDef] = React342.useState(null);
34034
- const [connectingNetwork, setConnectingNetwork] = React342.useState(null);
34035
- const [walletError, setWalletError] = React342.useState(null);
34036
- const [isWalletConnecting, setIsWalletConnecting] = React342.useState(false);
34037
- const [eip6963ProviderCount, setEip6963ProviderCount] = React342.useState(0);
34038
- React342.useEffect(() => {
34311
+ const [autoResolved, setAutoResolved] = React352.useState(false);
34312
+ const [selectedWalletDef, setSelectedWalletDef] = React352.useState(null);
34313
+ const [connectingNetwork, setConnectingNetwork] = React352.useState(null);
34314
+ const [walletError, setWalletError] = React352.useState(null);
34315
+ const [isWalletConnecting, setIsWalletConnecting] = React352.useState(false);
34316
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React352.useState(0);
34317
+ React352.useEffect(() => {
34039
34318
  const store = getEip6963Store();
34040
34319
  if (!store) return;
34041
34320
  setEip6963ProviderCount(store.getProviders().length);
@@ -34044,7 +34323,7 @@ function WalletConnect({
34044
34323
  });
34045
34324
  }, []);
34046
34325
  const { wallets: backendWallets } = useExternalWallets({ publishableKey });
34047
- const walletDefinitions = React342.useMemo(
34326
+ const walletDefinitions = React352.useMemo(
34048
34327
  () => backendWallets.length > 0 ? backendWallets.map((w) => ({
34049
34328
  id: w.id,
34050
34329
  name: w.name,
@@ -34055,32 +34334,32 @@ function WalletConnect({
34055
34334
  })) : FALLBACK_WALLET_DEFINITIONS,
34056
34335
  [backendWallets]
34057
34336
  );
34058
- const [recentWalletId, setRecentWalletIdState] = React342.useState(getLastOpenedWallet);
34059
- React342.useEffect(() => {
34337
+ const [recentWalletId, setRecentWalletIdState] = React352.useState(getLastOpenedWallet);
34338
+ React352.useEffect(() => {
34060
34339
  if (view === "select_wallet") {
34061
34340
  setRecentWalletIdState(getLastOpenedWallet());
34062
34341
  }
34063
34342
  }, [view]);
34064
- const availableWallets = React342.useMemo(
34343
+ const availableWallets = React352.useMemo(
34065
34344
  () => detectAvailableWallets(walletDefinitions, recentWalletId),
34066
34345
  [walletDefinitions, eip6963ProviderCount, recentWalletId]
34067
34346
  );
34068
- const [isMobile, setIsMobile] = React342.useState(false);
34069
- React342.useEffect(() => {
34347
+ const [isMobile, setIsMobile] = React352.useState(false);
34348
+ React352.useEffect(() => {
34070
34349
  setIsMobile(isMobileDevice());
34071
34350
  }, []);
34072
- const mobileDepositAddresses = React342.useMemo(
34351
+ const mobileDepositAddresses = React352.useMemo(
34073
34352
  () => (depositWallets ?? []).map((w) => ({ chain_type: w.chain_type, address: w.address })),
34074
34353
  [depositWallets]
34075
34354
  );
34076
- const mobileDepositWalletIds = React342.useMemo(
34355
+ const mobileDepositWalletIds = React352.useMemo(
34077
34356
  () => (depositWallets ?? []).filter((w) => w.chain_type === "ethereum" || w.chain_type === "solana").map((w) => w.id),
34078
34357
  [depositWallets]
34079
34358
  );
34080
- const [mobileRedirect, setMobileRedirect] = React342.useState(null);
34081
- const [pendingMobileWallet, setPendingMobileWallet] = React342.useState(null);
34082
- const [awaitingMobileDeposit, setAwaitingMobileDeposit] = React342.useState(false);
34083
- React342.useEffect(() => {
34359
+ const [mobileRedirect, setMobileRedirect] = React352.useState(null);
34360
+ const [pendingMobileWallet, setPendingMobileWallet] = React352.useState(null);
34361
+ const [awaitingMobileDeposit, setAwaitingMobileDeposit] = React352.useState(false);
34362
+ React352.useEffect(() => {
34084
34363
  if (!standalone || autoResolved || detectingWallet) return;
34085
34364
  if (!detectedWallet) {
34086
34365
  setAutoResolved(true);
@@ -34106,32 +34385,36 @@ function WalletConnect({
34106
34385
  depositWallets,
34107
34386
  depositWalletsLoading
34108
34387
  ]);
34109
- React342.useEffect(() => {
34388
+ React352.useEffect(() => {
34110
34389
  if (!standalone || autoResolved) return;
34111
34390
  const t13 = setTimeout(() => setAutoResolved(true), 5e3);
34112
34391
  return () => clearTimeout(t13);
34113
34392
  }, [standalone, autoResolved]);
34114
- const [balances, setBalances] = React342.useState([]);
34115
- const [isLoading, setIsLoading] = React342.useState(false);
34116
- const [selectedBalance, setSelectedBalance] = React342.useState(null);
34117
- const [totalBalanceUsd, setTotalBalanceUsd] = React342.useState(null);
34118
- const [error, setError] = React342.useState(null);
34119
- const [isDisconnectingWallet, setIsDisconnectingWallet] = React342.useState(false);
34120
- const [amountUsd, setAmountUsd] = React342.useState(prefillAmountUsd ?? "");
34121
- const [isConfirming, setIsConfirming] = React342.useState(false);
34122
- const [hasSignedTransaction, setHasSignedTransaction] = React342.useState(false);
34123
- const [tokenChainDetails, setTokenChainDetails] = React342.useState(null);
34124
- const [loadingTokenDetails, setLoadingTokenDetails] = React342.useState(false);
34125
- const [showTransactionDetails, setShowTransactionDetails] = React342.useState(false);
34126
- const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React342.useState(null);
34393
+ const [balances, setBalances] = React352.useState([]);
34394
+ const [isLoading, setIsLoading] = React352.useState(false);
34395
+ const [selectedBalance, setSelectedBalance] = React352.useState(null);
34396
+ const [totalBalanceUsd, setTotalBalanceUsd] = React352.useState(null);
34397
+ const [error, setError] = React352.useState(null);
34398
+ const [isDisconnectingWallet, setIsDisconnectingWallet] = React352.useState(false);
34399
+ const [amountUsd, setAmountUsd] = React352.useState(prefilledAmountUsd ?? "");
34400
+ const [isConfirming, setIsConfirming] = React352.useState(false);
34401
+ const [hasSignedTransaction, setHasSignedTransaction] = React352.useState(false);
34402
+ const [tokenChainDetails, setTokenChainDetails] = React352.useState(null);
34403
+ const [loadingTokenDetails, setLoadingTokenDetails] = React352.useState(false);
34404
+ const [showTransactionDetails, setShowTransactionDetails] = React352.useState(false);
34405
+ const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React352.useState(null);
34127
34406
  const walletInfo = activeWalletInfo;
34128
34407
  const depositWallet = activeDepositWallet;
34129
34408
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
34409
+ React352.useEffect(() => {
34410
+ const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
34411
+ setAmountUsd(cleanedPrefilled);
34412
+ }, [prefilledAmountUsd]);
34130
34413
  const chainType = activeDepositWallet?.chain_type ?? "ethereum";
34131
34414
  const recipientAddress = activeDepositWallet?.address ?? "";
34132
34415
  const isCheckoutMode = !!checkoutAmountUsd;
34133
34416
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" || chainType === "cardano" || chainType === "n1" ? "ethereum" : chainType;
34134
- const transitionTo = React342.useCallback((nextView) => {
34417
+ const transitionTo = React352.useCallback((nextView) => {
34135
34418
  if (nextView === viewRef.current) return;
34136
34419
  setIsTransitioning(true);
34137
34420
  setTimeout(() => {
@@ -34196,7 +34479,7 @@ function WalletConnect({
34196
34479
  if (!selectedWalletDef) return;
34197
34480
  handleConnectWallet(selectedWalletDef, network);
34198
34481
  };
34199
- React342.useEffect(() => {
34482
+ React352.useEffect(() => {
34200
34483
  if (!pendingMobileWallet) return;
34201
34484
  if (mobileDepositAddresses.length > 0) {
34202
34485
  const wallet = pendingMobileWallet;
@@ -34360,7 +34643,7 @@ function WalletConnect({
34360
34643
  publishableKey,
34361
34644
  enabled: !!activeWalletInfo && !!recipientAddress
34362
34645
  });
34363
- const effectiveDestinationAmount = React342.useMemo(() => {
34646
+ const effectiveDestinationAmount = React352.useMemo(() => {
34364
34647
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
34365
34648
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
34366
34649
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -34388,7 +34671,7 @@ function WalletConnect({
34388
34671
  stablecoinParity,
34389
34672
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
34390
34673
  });
34391
- const activeCheckoutQuote = React342.useMemo(() => {
34674
+ const activeCheckoutQuote = React352.useMemo(() => {
34392
34675
  if (!isCheckoutMode) return null;
34393
34676
  if (walletCheckoutQuote)
34394
34677
  return {
@@ -34418,10 +34701,10 @@ function WalletConnect({
34418
34701
  onDepositSuccess,
34419
34702
  onDepositError
34420
34703
  });
34421
- React342.useEffect(() => {
34704
+ React352.useEffect(() => {
34422
34705
  onExecutionsChange?.(depositExecutions);
34423
34706
  }, [depositExecutions, onExecutionsChange]);
34424
- const latestDepositExecution = React342.useMemo(() => {
34707
+ const latestDepositExecution = React352.useMemo(() => {
34425
34708
  if (depositExecutions.length === 0) return null;
34426
34709
  return [...depositExecutions].sort((a, b) => {
34427
34710
  const ta = a.created_at ? new Date(a.created_at).getTime() : 0;
@@ -34429,21 +34712,21 @@ function WalletConnect({
34429
34712
  return tb - ta;
34430
34713
  })[0];
34431
34714
  }, [depositExecutions]);
34432
- React342.useEffect(() => {
34715
+ React352.useEffect(() => {
34433
34716
  if (awaitingMobileDeposit && latestDepositExecution && (viewRef.current === "mobile_redirect" || viewRef.current === "connecting")) {
34434
34717
  transitionTo("mobile_deposit_status");
34435
34718
  }
34436
34719
  }, [awaitingMobileDeposit, latestDepositExecution, transitionTo]);
34437
- React342.useEffect(() => {
34438
- if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
34720
+ React352.useEffect(() => {
34721
+ if (!isCheckoutMode || !tokenChainDetails || view !== "enter_amount") return;
34439
34722
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
34440
34723
  const currentAmount = parseFloat(amountUsd) || 0;
34441
34724
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
34442
- }, [tokenChainDetails, view, prefillAmountUsd]);
34443
- React342.useEffect(() => {
34725
+ }, [isCheckoutMode, tokenChainDetails, view, amountUsd]);
34726
+ React352.useEffect(() => {
34444
34727
  if (view === "review") setShowTransactionDetails(false);
34445
34728
  }, [view]);
34446
- React342.useEffect(() => {
34729
+ React352.useEffect(() => {
34447
34730
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet)
34448
34731
  return;
34449
34732
  let cancelled = false;
@@ -34480,7 +34763,7 @@ function WalletConnect({
34480
34763
  cancelled = true;
34481
34764
  };
34482
34765
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
34483
- React342.useEffect(() => {
34766
+ React352.useEffect(() => {
34484
34767
  if (!activeWalletInfo || !activeDepositWallet) return;
34485
34768
  let cancelled = false;
34486
34769
  setIsLoading(true);
@@ -34545,21 +34828,21 @@ function WalletConnect({
34545
34828
  defaultSourceTokenAddress,
34546
34829
  defaultSourceSymbol
34547
34830
  ]);
34548
- const usdToTokenRate = React342.useMemo(() => {
34831
+ const usdToTokenRate = React352.useMemo(() => {
34549
34832
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
34550
34833
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
34551
34834
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
34552
34835
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
34553
34836
  return balanceAmount / balanceUsd;
34554
34837
  }, [selectedBalance, selectedToken]);
34555
- const tokenAmount = React342.useMemo(() => {
34838
+ const tokenAmount = React352.useMemo(() => {
34556
34839
  if (isCheckoutMode && activeCheckoutQuote && selectedToken)
34557
34840
  return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
34558
34841
  const usdNum = parseFloat(amountUsd) || 0;
34559
34842
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
34560
34843
  return usdNum * usdToTokenRate;
34561
34844
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
34562
- React342.useEffect(() => {
34845
+ React352.useEffect(() => {
34563
34846
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount")
34564
34847
  setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
34565
34848
  }, [isCheckoutMode, activeCheckoutQuote, view]);
@@ -34568,7 +34851,7 @@ function WalletConnect({
34568
34851
  const inputUsdNum = parseFloat(amountUsd) || 0;
34569
34852
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
34570
34853
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
34571
- const formattedTokenAmount = React342.useMemo(() => {
34854
+ const formattedTokenAmount = React352.useMemo(() => {
34572
34855
  if (tokenAmount === 0 || !selectedToken) return null;
34573
34856
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
34574
34857
  }, [tokenAmount, selectedToken]);
@@ -34601,7 +34884,7 @@ function WalletConnect({
34601
34884
  break;
34602
34885
  case "enter_amount":
34603
34886
  transitionTo("select_token");
34604
- setAmountUsd(prefillAmountUsd ?? "");
34887
+ setAmountUsd(prefilledAmountUsd ?? "");
34605
34888
  setTokenChainDetails(null);
34606
34889
  break;
34607
34890
  case "review":
@@ -34633,7 +34916,7 @@ function WalletConnect({
34633
34916
  setSelectedBalance(null);
34634
34917
  setBalances([]);
34635
34918
  setTotalBalanceUsd(null);
34636
- setAmountUsd(prefillAmountUsd ?? "");
34919
+ setAmountUsd(prefilledAmountUsd ?? "");
34637
34920
  setError(null);
34638
34921
  };
34639
34922
  if (standalone) {
@@ -35357,6 +35640,15 @@ function SkeletonButton({ variant = "default" }) {
35357
35640
  ] });
35358
35641
  }
35359
35642
  var t8 = i18n2.depositModal;
35643
+ function normalizePrefilledUsdAmount(value) {
35644
+ if (!value) return void 0;
35645
+ const cleaned = value.replace(/[^0-9.]/g, "");
35646
+ if (!cleaned) return void 0;
35647
+ const normalizedNumeric = cleaned.replace(/(\..*)\./g, "$1");
35648
+ const parsed = parseFloat(normalizedNumeric);
35649
+ if (!Number.isFinite(parsed) || parsed <= 0) return void 0;
35650
+ return parseFloat(parsed.toFixed(2)).toString();
35651
+ }
35360
35652
  function depositTabForScreen(screen) {
35361
35653
  return screen === "card" || screen === "cashapp" || screen === "bank_transfer" || screen === "stripe_link" || screen === "apple_pay" ? "cash" : "crypto";
35362
35654
  }
@@ -35376,6 +35668,7 @@ function DepositModal({
35376
35668
  defaultSourceChainId,
35377
35669
  defaultSourceTokenAddress,
35378
35670
  defaultSourceSymbol,
35671
+ prefilledAmountUsd,
35379
35672
  hideDepositTracker,
35380
35673
  showBalanceHeader = false,
35381
35674
  transferInputVariant = "double_input",
@@ -35411,6 +35704,10 @@ function DepositModal({
35411
35704
  depositTrackerSubTitle = t8.depositTracker.subtitle
35412
35705
  }) {
35413
35706
  const { colors: colors2, fonts, components } = useTheme();
35707
+ const normalizedPrefilledAmountUsd = (0, import_react8.useMemo)(
35708
+ () => normalizePrefilledUsdAmount(prefilledAmountUsd),
35709
+ [prefilledAmountUsd]
35710
+ );
35414
35711
  const onDepositSuccessFor = (0, import_react8.useCallback)(
35415
35712
  (method) => onDepositSuccess || onEvent ? (data) => {
35416
35713
  const payload = { ...data, method };
@@ -36276,6 +36573,7 @@ function DepositModal({
36276
36573
  defaultSourceChainId,
36277
36574
  defaultSourceTokenAddress,
36278
36575
  defaultSourceSymbol,
36576
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
36279
36577
  depositConfirmationMode,
36280
36578
  onExecutionsChange: setDepositExecutions,
36281
36579
  onDepositSuccess: onDepositSuccessFor("transfer"),
@@ -36295,6 +36593,7 @@ function DepositModal({
36295
36593
  defaultSourceChainId,
36296
36594
  defaultSourceTokenAddress,
36297
36595
  defaultSourceSymbol,
36596
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
36298
36597
  depositConfirmationMode,
36299
36598
  onExecutionsChange: setDepositExecutions,
36300
36599
  onDepositSuccess: onDepositSuccessFor("transfer"),
@@ -36379,7 +36678,8 @@ function DepositModal({
36379
36678
  wallets,
36380
36679
  assetCdnUrl: projectConfig?.asset_cdn_url,
36381
36680
  hideDepositFlowInfo,
36382
- hideDisplayDescription
36681
+ hideDisplayDescription,
36682
+ prefilledAmountUsd: normalizedPrefilledAmountUsd
36383
36683
  }
36384
36684
  ),
36385
36685
  depositPoweredByFooter
@@ -36444,7 +36744,8 @@ function DepositModal({
36444
36744
  defaultSourceChainType,
36445
36745
  defaultSourceChainId,
36446
36746
  defaultSourceTokenAddress,
36447
- defaultSourceSymbol
36747
+ defaultSourceSymbol,
36748
+ prefilledAmountUsd: normalizedPrefilledAmountUsd
36448
36749
  }
36449
36750
  ),
36450
36751
  depositPoweredByFooter
@@ -36476,6 +36777,7 @@ function DepositModal({
36476
36777
  onDepositSuccess: onDepositSuccessFor("wallet_connect"),
36477
36778
  onDepositError: onDepositErrorFor("wallet_connect"),
36478
36779
  amountQuickSelect: browserWalletAmountQuickSelect,
36780
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
36479
36781
  onWalletDisconnect: handleWalletDisconnect,
36480
36782
  onWalletConnected: (info, dw) => {
36481
36783
  setBrowserWalletInfo({ ...info, depositWallet: dw });
@@ -36524,7 +36826,8 @@ function DepositModal({
36524
36826
  assetCdnUrl: projectConfig?.asset_cdn_url,
36525
36827
  onEvent,
36526
36828
  onDepositSuccess,
36527
- onDepositError
36829
+ onDepositError,
36830
+ prefilledAmountUsd: normalizedPrefilledAmountUsd
36528
36831
  }
36529
36832
  ),
36530
36833
  depositPoweredByFooter
@@ -36536,7 +36839,7 @@ function DepositModal({
36536
36839
  title: "Deposit with Link",
36537
36840
  showBack: stripeLinkStep !== "checkout" && stripeLinkStep !== "success",
36538
36841
  onBack: handleBack,
36539
- showClose: stripeLinkStep !== "checkout",
36842
+ showClose: stripeLinkStep !== "checkout" && stripeLinkStep !== "auth",
36540
36843
  onClose: handleClose
36541
36844
  }
36542
36845
  ),
@@ -36567,6 +36870,8 @@ function DepositModal({
36567
36870
  destinationChainType,
36568
36871
  destinationChainId,
36569
36872
  destinationTokenAddress,
36873
+ countryCode: userIpInfo?.alpha2,
36874
+ subdivisionCode: userIpInfo?.subdivisionCode ?? void 0,
36570
36875
  wallets,
36571
36876
  email: userEmail,
36572
36877
  iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/link.svg` : void 0,
@@ -36606,6 +36911,7 @@ function DepositModal({
36606
36911
  onEvent,
36607
36912
  onDepositSuccess: onDepositSuccessFor("cashapp"),
36608
36913
  onDepositError: onDepositErrorFor("cashapp"),
36914
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
36609
36915
  wallets
36610
36916
  }
36611
36917
  ),
@@ -36664,7 +36970,7 @@ function DepositModal({
36664
36970
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "expired", "refunded", "canceled"]);
36665
36971
  function usePaymentIntent(params) {
36666
36972
  const { clientSecret, publishableKey, enabled = true, pollingInterval = 3e3 } = params;
36667
- return (0, import_react_query19.useQuery)({
36973
+ return (0, import_react_query20.useQuery)({
36668
36974
  queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
36669
36975
  queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
36670
36976
  enabled: enabled && !!clientSecret && !!publishableKey,
@@ -37305,7 +37611,7 @@ function CheckoutModal({
37305
37611
  userId: paymentIntent.user_id || "",
37306
37612
  publishableKey,
37307
37613
  clientSecret,
37308
- prefillAmountUsd: remainingAmountUsd,
37614
+ prefilledAmountUsd: remainingAmountUsd,
37309
37615
  checkoutAmountUsd: paymentIntent.amount_usd,
37310
37616
  checkoutReceivedUsd: paymentIntent.amount_received_usd,
37311
37617
  checkoutDestination: {
@@ -37366,7 +37672,7 @@ function CheckoutModal({
37366
37672
  ) }) });
37367
37673
  }
37368
37674
  function useSupportedDestinationTokens(publishableKey, enabled = true) {
37369
- return (0, import_react_query20.useQuery)({
37675
+ return (0, import_react_query21.useQuery)({
37370
37676
  queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
37371
37677
  queryFn: () => getSupportedDestinationTokens(publishableKey),
37372
37678
  staleTime: 1e3 * 60 * 5,
@@ -37401,7 +37707,7 @@ function useSourceTokenValidation(params) {
37401
37707
  enabled = true
37402
37708
  } = params;
37403
37709
  const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
37404
- return (0, import_react_query21.useQuery)({
37710
+ return (0, import_react_query22.useQuery)({
37405
37711
  queryKey: [
37406
37712
  "unifold",
37407
37713
  "sourceTokenValidation",
@@ -37450,7 +37756,7 @@ function useSourceTokenValidation(params) {
37450
37756
  function useAddressBalance(params) {
37451
37757
  const { address, chainType, chainId, tokenAddress, publishableKey, enabled = true } = params;
37452
37758
  const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
37453
- return (0, import_react_query22.useQuery)({
37759
+ return (0, import_react_query23.useQuery)({
37454
37760
  queryKey: [
37455
37761
  "unifold",
37456
37762
  "addressBalance",
@@ -37506,7 +37812,7 @@ function useAddressBalance(params) {
37506
37812
  }
37507
37813
  function useExecutions(userId, publishableKey, options) {
37508
37814
  const actionType = options?.actionType ?? ActionType.Deposit;
37509
- return (0, import_react_query23.useQuery)({
37815
+ return (0, import_react_query24.useQuery)({
37510
37816
  queryKey: ["unifold", "executions", actionType, userId, publishableKey],
37511
37817
  queryFn: () => queryExecutions(userId, publishableKey, actionType),
37512
37818
  enabled: (options?.enabled ?? true) && !!userId,
@@ -37832,7 +38138,7 @@ function useVerifyRecipientAddress(params) {
37832
38138
  } = params;
37833
38139
  const trimmedAddress = recipientAddress?.trim() || "";
37834
38140
  const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
37835
- return (0, import_react_query24.useQuery)({
38141
+ return (0, import_react_query25.useQuery)({
37836
38142
  queryKey: [
37837
38143
  "unifold",
37838
38144
  "verifyRecipientAddress",
@@ -37871,7 +38177,7 @@ function useGetDepositAddress(params) {
37871
38177
  enabled = true
37872
38178
  } = params;
37873
38179
  const canFire = !!userId && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
37874
- return (0, import_react_query25.useQuery)({
38180
+ return (0, import_react_query26.useQuery)({
37875
38181
  queryKey: [
37876
38182
  "unifold",
37877
38183
  "getDepositAddress",
@@ -39671,6 +39977,7 @@ function UnifoldProvider2({
39671
39977
  defaultSourceChainId: depositConfig.defaultSourceChainId,
39672
39978
  defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
39673
39979
  defaultSourceSymbol: depositConfig.defaultSourceSymbol,
39980
+ prefilledAmountUsd: depositConfig.prefilledAmountUsd,
39674
39981
  userEmail: depositConfig.user?.email,
39675
39982
  depositConfirmationMode: depositConfig.depositConfirmationMode ?? "auto_ui",
39676
39983
  hideDepositTracker: config?.hideDepositTracker,