@unifold/connect-react 0.1.68 → 0.1.70-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1211,7 +1211,10 @@ var import_react41 = __toESM(require("react"));
1211
1211
  var import_react = require("react");
1212
1212
  var import_react_query = require("@tanstack/react-query");
1213
1213
  var import_jsx_runtime = require("react/jsx-runtime");
1214
- var UnifoldContext = (0, import_react.createContext)(null);
1214
+ var UNIFOLD_CONTEXT_KEY = /* @__PURE__ */ Symbol.for("unifold.react-provider.context");
1215
+ var globalRef = globalThis;
1216
+ var UnifoldContext = globalRef[UNIFOLD_CONTEXT_KEY] ?? (0, import_react.createContext)(null);
1217
+ globalRef[UNIFOLD_CONTEXT_KEY] = UnifoldContext;
1215
1218
  var createQueryClient = () => new import_react_query.QueryClient({
1216
1219
  defaultOptions: {
1217
1220
  queries: {
@@ -6190,10 +6193,15 @@ var import_jsx_runtime18 = require("react/jsx-runtime");
6190
6193
  var React211 = __toESM(require("react"), 1);
6191
6194
  var import_jsx_runtime19 = require("react/jsx-runtime");
6192
6195
  var import_jsx_runtime20 = require("react/jsx-runtime");
6196
+ var React52 = __toESM(require("react"), 1);
6193
6197
  var import_react9 = require("react");
6198
+ var import_react_query3 = require("@tanstack/react-query");
6194
6199
 
6195
6200
  // ../core/dist/index.mjs
6196
6201
  var import_react_query2 = require("@tanstack/react-query");
6202
+ var __defProp2 = Object.defineProperty;
6203
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6204
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
6197
6205
  function formatStablecoinAmount(baseUnits, decimals) {
6198
6206
  const raw = Number(baseUnits) / 10 ** decimals;
6199
6207
  const floored = Math.floor(raw * 100) / 100;
@@ -6287,6 +6295,16 @@ var ActionType = /* @__PURE__ */ ((ActionType2) => {
6287
6295
  ActionType2["Withdraw"] = "withdraw";
6288
6296
  return ActionType2;
6289
6297
  })(ActionType || {});
6298
+ var DepositAddressValidationError = class extends Error {
6299
+ constructor(message) {
6300
+ super(message);
6301
+ __publicField(this, "isDepositAddressValidationError", true);
6302
+ this.name = "DepositAddressValidationError";
6303
+ }
6304
+ };
6305
+ function isDepositAddressValidationError(error) {
6306
+ return error instanceof Error && error.isDepositAddressValidationError === true;
6307
+ }
6290
6308
  async function createDepositAddress(overrides, publishableKey) {
6291
6309
  if (!overrides?.external_user_id) {
6292
6310
  throw new Error("external_user_id is required");
@@ -6314,6 +6332,13 @@ async function createDepositAddress(overrides, publishableKey) {
6314
6332
  body: JSON.stringify(payload)
6315
6333
  });
6316
6334
  if (!response.ok) {
6335
+ if (response.status === 400) {
6336
+ const body = await response.json().catch(() => null);
6337
+ if (body?.error_type === "validation_error") {
6338
+ const firstError = Array.isArray(body.details?.errors) ? body.details?.errors[0] : void 0;
6339
+ throw new DepositAddressValidationError(firstError ?? "Invalid recipient address");
6340
+ }
6341
+ }
6317
6342
  throw new Error(`Failed to create EOA: ${response.statusText}`);
6318
6343
  }
6319
6344
  return response.json();
@@ -6484,6 +6509,27 @@ async function getFiatCurrencies(publishableKey) {
6484
6509
  }
6485
6510
  return response.json();
6486
6511
  }
6512
+ async function getFiatExchangeRates(options = {}, publishableKey) {
6513
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
6514
+ validatePublishableKey(pk);
6515
+ const params = new URLSearchParams();
6516
+ if (options.currencies && options.currencies.length > 0) {
6517
+ params.set("currencies", options.currencies.join(","));
6518
+ }
6519
+ const queryString = params.toString();
6520
+ const url = `${API_BASE_URL}/v1/public/exchange_rates/fiat_currencies${queryString ? `?${queryString}` : ""}`;
6521
+ const response = await fetch(url, {
6522
+ method: "GET",
6523
+ headers: {
6524
+ accept: "application/json",
6525
+ "x-publishable-key": pk
6526
+ }
6527
+ });
6528
+ if (!response.ok) {
6529
+ throw new Error(`Failed to fetch fiat exchange rates: ${response.statusText}`);
6530
+ }
6531
+ return response.json();
6532
+ }
6487
6533
  async function getOnrampQuotes(request, publishableKey) {
6488
6534
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
6489
6535
  validatePublishableKey(pk);
@@ -6649,6 +6695,21 @@ async function getProjectConfig(publishableKey, options) {
6649
6695
  const data = await response.json();
6650
6696
  return data;
6651
6697
  }
6698
+ async function getPublicIncident(publishableKey) {
6699
+ const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
6700
+ validatePublishableKey(pk);
6701
+ const response = await fetch(`${API_BASE_URL}/v1/public/projects/incident`, {
6702
+ method: "GET",
6703
+ headers: {
6704
+ accept: "application/json",
6705
+ "x-publishable-key": pk
6706
+ }
6707
+ });
6708
+ if (!response.ok) {
6709
+ throw new Error(`Failed to fetch public incident: ${response.statusText}`);
6710
+ }
6711
+ return response.json();
6712
+ }
6652
6713
  async function getIpAddress() {
6653
6714
  const response = await fetch(`${API_BASE_URL}/v1/public/ip_address`, {
6654
6715
  method: "GET",
@@ -6704,7 +6765,7 @@ async function getExternalWallets(publishableKey) {
6704
6765
  const data = await response.json();
6705
6766
  return data;
6706
6767
  }
6707
- async function getWalletMobileDeepLink(wallet, depositAddresses, publishableKey) {
6768
+ async function getWalletMobileDeepLink(wallet, depositAddresses, publishableKey, amountUsd) {
6708
6769
  const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
6709
6770
  validatePublishableKey(pk);
6710
6771
  const response = await fetch(`${API_BASE_URL}/v1/public/external_wallets/mobile_deeplink`, {
@@ -6714,7 +6775,11 @@ async function getWalletMobileDeepLink(wallet, depositAddresses, publishableKey)
6714
6775
  accept: "application/json",
6715
6776
  "x-publishable-key": pk
6716
6777
  },
6717
- body: JSON.stringify({ wallet, deposit_addresses: depositAddresses })
6778
+ body: JSON.stringify({
6779
+ wallet,
6780
+ deposit_addresses: depositAddresses,
6781
+ ...amountUsd ? { amount_usd: amountUsd } : {}
6782
+ })
6718
6783
  });
6719
6784
  if (!response.ok) {
6720
6785
  throw new Error(`Failed to generate wallet deep link: ${response.statusText}`);
@@ -6759,6 +6824,15 @@ async function verifyRecipientAddress(request, publishableKey) {
6759
6824
  body: JSON.stringify(request)
6760
6825
  });
6761
6826
  if (!response.ok) {
6827
+ const body = await response.json().catch(() => null);
6828
+ if (response.status === 400 && body?.error_type === "validation_error") {
6829
+ const firstError = Array.isArray(body.details?.errors) ? body.details?.errors[0] : void 0;
6830
+ return {
6831
+ valid: false,
6832
+ failure_code: "validation_error",
6833
+ message: firstError ?? "Invalid recipient address"
6834
+ };
6835
+ }
6762
6836
  throw new Error(`Failed to verify recipient address: ${response.statusText}`);
6763
6837
  }
6764
6838
  return response.json();
@@ -7165,6 +7239,7 @@ async function stripeGetDefaultToken(params, publishableKey) {
7165
7239
  chain_type: params.chainType
7166
7240
  });
7167
7241
  if (params.countryCode) query.append("country_code", params.countryCode);
7242
+ if (params.subdivisionCode) query.append("subdivision_code", params.subdivisionCode);
7168
7243
  const response = await fetch(
7169
7244
  `${API_BASE_URL}${HEADLESS_STRIPE_BASE}/default_token?${query.toString()}`,
7170
7245
  {
@@ -7803,7 +7878,7 @@ var en_default = {
7803
7878
  var i18n = en_default;
7804
7879
 
7805
7880
  // ../ui-react/dist/index.mjs
7806
- var import_react_query3 = require("@tanstack/react-query");
7881
+ var import_react_query4 = require("@tanstack/react-query");
7807
7882
  var import_react10 = require("react");
7808
7883
  var import_react11 = require("react");
7809
7884
  var import_react12 = require("react");
@@ -7812,7 +7887,7 @@ var React42 = __toESM(require("react"), 1);
7812
7887
  var import_jsx_runtime22 = require("react/jsx-runtime");
7813
7888
  var import_jsx_runtime23 = require("react/jsx-runtime");
7814
7889
  var import_jsx_runtime24 = require("react/jsx-runtime");
7815
- var import_react_query4 = require("@tanstack/react-query");
7890
+ var import_react_query5 = require("@tanstack/react-query");
7816
7891
  var import_react13 = require("react");
7817
7892
  var import_jsx_runtime25 = require("react/jsx-runtime");
7818
7893
  var import_react14 = require("react");
@@ -7822,12 +7897,12 @@ var import_jsx_runtime26 = require("react/jsx-runtime");
7822
7897
  var import_jsx_runtime27 = require("react/jsx-runtime");
7823
7898
  var import_jsx_runtime28 = require("react/jsx-runtime");
7824
7899
  var import_jsx_runtime29 = require("react/jsx-runtime");
7825
- var React52 = __toESM(require("react"), 1);
7900
+ var React62 = __toESM(require("react"), 1);
7826
7901
  var import_react17 = require("react");
7827
- var import_react_query5 = require("@tanstack/react-query");
7828
- var import_react18 = require("react");
7829
7902
  var import_react_query6 = require("@tanstack/react-query");
7903
+ var import_react18 = require("react");
7830
7904
  var import_react_query7 = require("@tanstack/react-query");
7905
+ var import_react_query8 = require("@tanstack/react-query");
7831
7906
  var import_jsx_runtime30 = require("react/jsx-runtime");
7832
7907
  var import_react19 = require("react");
7833
7908
  var import_jsx_runtime31 = require("react/jsx-runtime");
@@ -7836,20 +7911,20 @@ var import_react21 = require("react");
7836
7911
  var import_qr_code_styling = __toESM(require_qr_code_styling(), 1);
7837
7912
  var import_jsx_runtime32 = require("react/jsx-runtime");
7838
7913
  var import_react22 = require("react");
7839
- var import_react_query8 = require("@tanstack/react-query");
7914
+ var import_react_query9 = require("@tanstack/react-query");
7840
7915
  var import_jsx_runtime33 = require("react/jsx-runtime");
7841
7916
  var import_react23 = require("react");
7842
- var import_react_query9 = require("@tanstack/react-query");
7917
+ var import_react_query10 = require("@tanstack/react-query");
7843
7918
  var import_jsx_runtime34 = require("react/jsx-runtime");
7844
7919
  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
7920
  var React72 = __toESM(require("react"), 1);
7848
- var import_jsx_runtime37 = require("react/jsx-runtime");
7921
+ var import_jsx_runtime36 = require("react/jsx-runtime");
7849
7922
  var React82 = __toESM(require("react"), 1);
7923
+ var import_jsx_runtime37 = require("react/jsx-runtime");
7924
+ var React92 = __toESM(require("react"), 1);
7850
7925
  var import_jsx_runtime38 = require("react/jsx-runtime");
7926
+ var React112 = __toESM(require("react"), 1);
7851
7927
  var React102 = __toESM(require("react"), 1);
7852
- var React92 = __toESM(require("react"), 1);
7853
7928
 
7854
7929
  // ../../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
7930
  var React25 = __toESM(require("react"), 1);
@@ -7997,15 +8072,15 @@ var cva = (base, config) => (props) => {
7997
8072
  // ../ui-react/dist/index.mjs
7998
8073
  var import_jsx_runtime39 = require("react/jsx-runtime");
7999
8074
  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
8075
  var React122 = __toESM(require("react"), 1);
8003
- var import_jsx_runtime42 = require("react/jsx-runtime");
8076
+ var import_jsx_runtime41 = require("react/jsx-runtime");
8004
8077
  var React132 = __toESM(require("react"), 1);
8005
- var import_jsx_runtime43 = require("react/jsx-runtime");
8078
+ var import_jsx_runtime42 = require("react/jsx-runtime");
8006
8079
  var React142 = __toESM(require("react"), 1);
8080
+ var import_jsx_runtime43 = require("react/jsx-runtime");
8081
+ var React152 = __toESM(require("react"), 1);
8007
8082
  var import_jsx_runtime44 = require("react/jsx-runtime");
8008
- var React282 = __toESM(require("react"), 1);
8083
+ var React292 = __toESM(require("react"), 1);
8009
8084
 
8010
8085
  // ../../node_modules/.pnpm/mipd@0.0.7_typescript@5.9.3/node_modules/mipd/dist/esm/utils.js
8011
8086
  function requestProviders(listener) {
@@ -8062,50 +8137,51 @@ function createStore() {
8062
8137
  }
8063
8138
 
8064
8139
  // ../ui-react/dist/index.mjs
8065
- var React152 = __toESM(require("react"), 1);
8066
8140
  var React162 = __toESM(require("react"), 1);
8067
- var import_jsx_runtime45 = require("react/jsx-runtime");
8068
8141
  var React172 = __toESM(require("react"), 1);
8069
- var import_jsx_runtime46 = require("react/jsx-runtime");
8142
+ var import_jsx_runtime45 = require("react/jsx-runtime");
8070
8143
  var React182 = __toESM(require("react"), 1);
8071
- var import_jsx_runtime47 = require("react/jsx-runtime");
8144
+ var import_jsx_runtime46 = require("react/jsx-runtime");
8072
8145
  var React192 = __toESM(require("react"), 1);
8073
- var import_jsx_runtime48 = require("react/jsx-runtime");
8146
+ var import_jsx_runtime47 = require("react/jsx-runtime");
8074
8147
  var React202 = __toESM(require("react"), 1);
8075
- var import_jsx_runtime49 = require("react/jsx-runtime");
8148
+ var import_jsx_runtime48 = require("react/jsx-runtime");
8076
8149
  var React212 = __toESM(require("react"), 1);
8077
- var import_jsx_runtime50 = require("react/jsx-runtime");
8150
+ var import_jsx_runtime49 = require("react/jsx-runtime");
8078
8151
  var React222 = __toESM(require("react"), 1);
8079
- var import_jsx_runtime51 = require("react/jsx-runtime");
8152
+ var import_jsx_runtime50 = require("react/jsx-runtime");
8080
8153
  var React232 = __toESM(require("react"), 1);
8081
- var import_jsx_runtime52 = require("react/jsx-runtime");
8154
+ var import_jsx_runtime51 = require("react/jsx-runtime");
8082
8155
  var React242 = __toESM(require("react"), 1);
8083
- var import_jsx_runtime53 = require("react/jsx-runtime");
8156
+ var import_jsx_runtime52 = require("react/jsx-runtime");
8084
8157
  var React252 = __toESM(require("react"), 1);
8085
- var import_jsx_runtime54 = require("react/jsx-runtime");
8158
+ var import_jsx_runtime53 = require("react/jsx-runtime");
8086
8159
  var React262 = __toESM(require("react"), 1);
8087
- var import_jsx_runtime55 = require("react/jsx-runtime");
8160
+ var import_jsx_runtime54 = require("react/jsx-runtime");
8088
8161
  var React272 = __toESM(require("react"), 1);
8162
+ var import_jsx_runtime55 = require("react/jsx-runtime");
8163
+ var React282 = __toESM(require("react"), 1);
8089
8164
  var import_jsx_runtime56 = require("react/jsx-runtime");
8090
8165
  var import_jsx_runtime57 = require("react/jsx-runtime");
8091
8166
  var import_jsx_runtime58 = require("react/jsx-runtime");
8092
- var React292 = __toESM(require("react"), 1);
8167
+ var React302 = __toESM(require("react"), 1);
8093
8168
  var import_jsx_runtime59 = require("react/jsx-runtime");
8094
8169
  var import_react24 = require("react");
8095
8170
  var import_jsx_runtime60 = require("react/jsx-runtime");
8096
8171
  var import_react25 = require("react");
8097
8172
  var import_jsx_runtime61 = require("react/jsx-runtime");
8098
8173
  var import_react26 = require("react");
8099
- var import_react_query10 = require("@tanstack/react-query");
8100
8174
  var import_react_query11 = require("@tanstack/react-query");
8101
8175
  var import_react_query12 = require("@tanstack/react-query");
8102
- var import_jsx_runtime62 = require("react/jsx-runtime");
8103
8176
  var import_react_query13 = require("@tanstack/react-query");
8177
+ var import_jsx_runtime62 = require("react/jsx-runtime");
8104
8178
  var import_react_query14 = require("@tanstack/react-query");
8105
8179
  var import_react_query15 = require("@tanstack/react-query");
8180
+ var import_react_query16 = require("@tanstack/react-query");
8181
+ var import_react_query17 = require("@tanstack/react-query");
8106
8182
  var import_react27 = require("react");
8107
8183
  var import_react28 = require("react");
8108
- var React312 = __toESM(require("react"), 1);
8184
+ var React322 = __toESM(require("react"), 1);
8109
8185
  var import_jsx_runtime63 = require("react/jsx-runtime");
8110
8186
  var import_jsx_runtime64 = require("react/jsx-runtime");
8111
8187
  var import_jsx_runtime65 = require("react/jsx-runtime");
@@ -10115,7 +10191,7 @@ var import_react30 = require("react");
10115
10191
  var import_jsx_runtime67 = require("react/jsx-runtime");
10116
10192
  var import_jsx_runtime68 = require("react/jsx-runtime");
10117
10193
  var import_react31 = require("react");
10118
- var React322 = __toESM(require("react"), 1);
10194
+ var React332 = __toESM(require("react"), 1);
10119
10195
 
10120
10196
  // ../../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
10197
  var React31 = __toESM(require("react"), 1);
@@ -12853,11 +12929,11 @@ var Content22 = TooltipContent;
12853
12929
 
12854
12930
  // ../ui-react/dist/index.mjs
12855
12931
  var import_jsx_runtime69 = require("react/jsx-runtime");
12856
- var import_react_query16 = require("@tanstack/react-query");
12932
+ var import_react_query18 = require("@tanstack/react-query");
12857
12933
  var import_jsx_runtime70 = require("react/jsx-runtime");
12858
12934
  var import_jsx_runtime71 = require("react/jsx-runtime");
12859
12935
  var import_react32 = require("react");
12860
- var React332 = __toESM(require("react"), 1);
12936
+ var React342 = __toESM(require("react"), 1);
12861
12937
 
12862
12938
  // ../../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
12939
  var React35 = __toESM(require("react"), 1);
@@ -14094,9 +14170,9 @@ var Separator = SelectSeparator;
14094
14170
  // ../ui-react/dist/index.mjs
14095
14171
  var import_jsx_runtime72 = require("react/jsx-runtime");
14096
14172
  var import_jsx_runtime73 = require("react/jsx-runtime");
14097
- var React342 = __toESM(require("react"), 1);
14098
- var import_react_query17 = require("@tanstack/react-query");
14099
- var import_react_query18 = require("@tanstack/react-query");
14173
+ var React352 = __toESM(require("react"), 1);
14174
+ var import_react_query19 = require("@tanstack/react-query");
14175
+ var import_react_query20 = require("@tanstack/react-query");
14100
14176
  var import_jsx_runtime74 = require("react/jsx-runtime");
14101
14177
  var import_jsx_runtime75 = require("react/jsx-runtime");
14102
14178
  var import_jsx_runtime76 = require("react/jsx-runtime");
@@ -14106,19 +14182,19 @@ var import_jsx_runtime78 = require("react/jsx-runtime");
14106
14182
  var import_jsx_runtime79 = require("react/jsx-runtime");
14107
14183
  var import_jsx_runtime80 = require("react/jsx-runtime");
14108
14184
  var import_react34 = require("react");
14109
- var import_react_query19 = require("@tanstack/react-query");
14185
+ var import_react_query21 = require("@tanstack/react-query");
14110
14186
  var import_jsx_runtime81 = require("react/jsx-runtime");
14111
14187
  var import_react35 = require("react");
14112
- var import_react_query20 = require("@tanstack/react-query");
14113
- var import_react_query21 = require("@tanstack/react-query");
14114
14188
  var import_react_query22 = require("@tanstack/react-query");
14115
14189
  var import_react_query23 = require("@tanstack/react-query");
14190
+ var import_react_query24 = require("@tanstack/react-query");
14191
+ var import_react_query25 = require("@tanstack/react-query");
14116
14192
  var import_react36 = require("react");
14117
14193
  var import_jsx_runtime82 = require("react/jsx-runtime");
14118
14194
  var import_react37 = require("react");
14119
- var import_react_query24 = require("@tanstack/react-query");
14195
+ var import_react_query26 = require("@tanstack/react-query");
14120
14196
  var import_react38 = require("react");
14121
- var import_react_query25 = require("@tanstack/react-query");
14197
+ var import_react_query27 = require("@tanstack/react-query");
14122
14198
  var import_jsx_runtime83 = require("react/jsx-runtime");
14123
14199
  var import_jsx_runtime84 = require("react/jsx-runtime");
14124
14200
  var import_react39 = require("react");
@@ -14675,7 +14751,7 @@ function useDepositAddress(params) {
14675
14751
  contractCalls,
14676
14752
  enabled = true
14677
14753
  } = params;
14678
- return (0, import_react_query3.useQuery)({
14754
+ return (0, import_react_query4.useQuery)({
14679
14755
  queryKey: [
14680
14756
  "unifold",
14681
14757
  "depositAddress",
@@ -14707,7 +14783,13 @@ function useDepositAddress(params) {
14707
14783
  // 24 hours in cache
14708
14784
  refetchOnMount: false,
14709
14785
  refetchOnWindowFocus: false,
14710
- retry: 3,
14786
+ // Don't retry recipient-address validation errors — they're deterministic
14787
+ // (a 400 won't succeed on retry) and we want to surface the invalid-address
14788
+ // screen immediately rather than after 3 backoff attempts.
14789
+ retry: (failureCount, error) => {
14790
+ if (isDepositAddressValidationError(error)) return false;
14791
+ return failureCount < 3;
14792
+ },
14711
14793
  retryDelay: (attempt) => Math.min(1e3 * 2 ** attempt, 1e4)
14712
14794
  // 1s, 2s, 4s (max 10s)
14713
14795
  });
@@ -14915,7 +14997,8 @@ function DepositHeader({
14915
14997
  balanceChainId,
14916
14998
  balanceTokenAddress,
14917
14999
  projectName,
14918
- publishableKey
15000
+ publishableKey,
15001
+ incident
14919
15002
  }) {
14920
15003
  const { colors: colors2, fonts, components } = useTheme();
14921
15004
  const [balance, setBalance] = (0, import_react12.useState)(null);
@@ -15013,19 +15096,64 @@ function DepositHeader({
15013
15096
  balanceTokenAddress,
15014
15097
  publishableKey
15015
15098
  ]);
15016
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-between uf-pb-6", children: [
15017
- showBack ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15018
- "button",
15019
- {
15020
- onClick: onBack,
15021
- className: "hover:uf-bg-secondary uf-rounded-lg uf-p-1 uf-transition-colors",
15022
- style: { color: components.header.buttonColor },
15023
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArrowLeft, { className: "uf-w-5 uf-h-5" })
15024
- }
15025
- ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "uf-w-5 uf-h-5 uf-invisible" }),
15026
- /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center", children: [
15027
- badge ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
15028
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15099
+ const incidentMessages = incident?.messages ?? [];
15100
+ const showIncident = incident?.enabled && incidentMessages.length > 0;
15101
+ const incidentSeverity = incident?.severity ?? "degraded";
15102
+ const incidentSeverityLabel = incidentSeverity === "outage" ? "Outage" : incidentSeverity === "info" ? "Info" : "Degraded service";
15103
+ const incidentStyles = incidentSeverity === "outage" ? {
15104
+ bg: "rgba(239, 68, 68, 0.12)",
15105
+ border: "rgba(239, 68, 68, 0.35)",
15106
+ text: "#fca5a5",
15107
+ link: "#fca5a5"
15108
+ } : incidentSeverity === "info" ? {
15109
+ bg: "rgba(59, 130, 246, 0.12)",
15110
+ border: "rgba(59, 130, 246, 0.35)",
15111
+ text: "#93c5fd",
15112
+ link: "#93c5fd"
15113
+ } : {
15114
+ bg: "rgba(245, 158, 11, 0.12)",
15115
+ border: "rgba(245, 158, 11, 0.35)",
15116
+ text: "#fcd34d",
15117
+ link: "#fcd34d"
15118
+ };
15119
+ const IncidentIcon = incidentSeverity === "info" ? Info : TriangleAlert;
15120
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { children: [
15121
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-between uf-pb-6", children: [
15122
+ showBack ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15123
+ "button",
15124
+ {
15125
+ onClick: onBack,
15126
+ className: "hover:uf-bg-secondary uf-rounded-lg uf-p-1 uf-transition-colors",
15127
+ style: { color: components.header.buttonColor },
15128
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(ArrowLeft, { className: "uf-w-5 uf-h-5" })
15129
+ }
15130
+ ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "uf-w-5 uf-h-5 uf-invisible" }),
15131
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center", children: [
15132
+ badge ? /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
15133
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15134
+ DialogTitle2,
15135
+ {
15136
+ className: "uf-text-center uf-text-base",
15137
+ style: {
15138
+ color: components.header.titleColor,
15139
+ fontFamily: fonts.medium
15140
+ },
15141
+ children: title
15142
+ }
15143
+ ),
15144
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15145
+ "div",
15146
+ {
15147
+ className: "uf-px-2 uf-py-0.5 uf-rounded-full uf-text-[10px]",
15148
+ style: {
15149
+ backgroundColor: colors2.card,
15150
+ color: colors2.foregroundMuted,
15151
+ fontFamily: fonts.regular
15152
+ },
15153
+ children: badge.count
15154
+ }
15155
+ )
15156
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15029
15157
  DialogTitle2,
15030
15158
  {
15031
15159
  className: "uf-text-center uf-text-base",
@@ -15036,61 +15164,91 @@ function DepositHeader({
15036
15164
  children: title
15037
15165
  }
15038
15166
  ),
15039
- /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15167
+ subtitle ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15040
15168
  "div",
15041
15169
  {
15042
- className: "uf-px-2 uf-py-0.5 uf-rounded-full uf-text-[10px]",
15170
+ className: "uf-text-xs uf-mt-1",
15043
15171
  style: {
15044
- backgroundColor: colors2.card,
15045
15172
  color: colors2.foregroundMuted,
15046
15173
  fontFamily: fonts.regular
15047
15174
  },
15048
- children: badge.count
15175
+ children: subtitle
15049
15176
  }
15050
- )
15051
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15052
- DialogTitle2,
15053
- {
15054
- className: "uf-text-center uf-text-base",
15055
- style: {
15056
- color: components.header.titleColor,
15057
- fontFamily: fonts.medium
15058
- },
15059
- children: title
15060
- }
15061
- ),
15062
- subtitle ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15063
- "div",
15064
- {
15065
- className: "uf-text-xs uf-mt-1",
15066
- style: {
15067
- color: colors2.foregroundMuted,
15068
- fontFamily: fonts.regular
15069
- },
15070
- children: subtitle
15071
- }
15072
- ) : showBalanceBlock ? isLoadingBalance && showBalanceSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded uf-animate-pulse uf-mt-1" }) : balance ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15073
- "div",
15177
+ ) : showBalanceBlock ? isLoadingBalance && showBalanceSkeleton ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "uf-h-3 uf-w-32 uf-bg-muted uf-rounded uf-animate-pulse uf-mt-1" }) : balance ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15178
+ "div",
15179
+ {
15180
+ className: "uf-text-xs uf-mt-1",
15181
+ style: {
15182
+ color: colors2.foregroundMuted,
15183
+ fontFamily: fonts.regular
15184
+ },
15185
+ children: formatBalanceDisplay(balance, projectName)
15186
+ }
15187
+ ) : null : null
15188
+ ] }),
15189
+ showClose ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15190
+ "button",
15074
15191
  {
15075
- className: "uf-text-xs uf-mt-1",
15076
- style: {
15077
- color: colors2.foregroundMuted,
15078
- fontFamily: fonts.regular
15079
- },
15080
- children: formatBalanceDisplay(balance, projectName)
15192
+ onClick: onClose,
15193
+ className: "hover:uf-bg-secondary uf-rounded-lg uf-p-1 uf-transition-colors",
15194
+ style: { color: components.header.buttonColor },
15195
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(X, { className: "uf-w-5 uf-h-5" })
15081
15196
  }
15082
- ) : null : null
15197
+ ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "uf-w-5 uf-h-5 uf-invisible" })
15083
15198
  ] }),
15084
- showClose ? /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15085
- "button",
15199
+ showIncident && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15200
+ "div",
15086
15201
  {
15087
- onClick: onClose,
15088
- className: "hover:uf-bg-secondary uf-rounded-lg uf-p-1 uf-transition-colors",
15089
- style: { color: components.header.buttonColor },
15090
- children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(X, { className: "uf-w-5 uf-h-5" })
15202
+ className: "uf-rounded-lg uf-px-3 uf-py-2.5 uf-mb-4",
15203
+ style: {
15204
+ backgroundColor: incidentStyles.bg,
15205
+ border: `1px solid ${incidentStyles.border}`
15206
+ },
15207
+ children: /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uf-flex uf-items-start uf-gap-2.5", children: [
15208
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15209
+ IncidentIcon,
15210
+ {
15211
+ className: "uf-w-4 uf-h-4 uf-mt-0.5 uf-shrink-0",
15212
+ style: { color: incidentStyles.text }
15213
+ }
15214
+ ),
15215
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { className: "uf-min-w-0 uf-flex-1", children: [
15216
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2 uf-mb-1.5", children: /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15217
+ "span",
15218
+ {
15219
+ className: "uf-text-[11px] uf-leading-none uf-px-1.5 uf-py-1 uf-rounded-md",
15220
+ style: {
15221
+ color: incidentStyles.text,
15222
+ border: `1px solid ${incidentStyles.border}`,
15223
+ fontFamily: fonts.medium
15224
+ },
15225
+ children: incidentSeverityLabel
15226
+ }
15227
+ ) }),
15228
+ /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15229
+ "div",
15230
+ {
15231
+ className: "uf-space-y-1",
15232
+ style: { color: incidentStyles.text, fontFamily: fonts.regular },
15233
+ children: incidentMessages.map((message, index2) => /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("p", { className: "uf-text-xs uf-leading-relaxed", children: message }, `${message}-${index2}`))
15234
+ }
15235
+ ),
15236
+ incident.statusPageUrl && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
15237
+ "a",
15238
+ {
15239
+ href: incident.statusPageUrl,
15240
+ target: "_blank",
15241
+ rel: "noreferrer",
15242
+ className: "uf-inline-block uf-mt-1.5 uf-text-xs uf-underline uf-underline-offset-2",
15243
+ style: { color: incidentStyles.link, fontFamily: fonts.medium },
15244
+ children: "View status"
15245
+ }
15246
+ )
15247
+ ] })
15248
+ ] })
15091
15249
  }
15092
- ) : /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("div", { className: "uf-w-5 uf-h-5 uf-invisible" })
15093
- ] }) });
15250
+ )
15251
+ ] });
15094
15252
  }
15095
15253
  function CurrencyListItem({ currency, isSelected, onSelect }) {
15096
15254
  const { colors: colors2, fonts, components } = useTheme();
@@ -15302,7 +15460,7 @@ function useUserIp2() {
15302
15460
  data: userIpInfo,
15303
15461
  isLoading,
15304
15462
  error
15305
- } = (0, import_react_query4.useQuery)({
15463
+ } = (0, import_react_query5.useQuery)({
15306
15464
  queryKey: ["unifold", "userIpInfo"],
15307
15465
  queryFn: async () => {
15308
15466
  const data = await getIpAddress();
@@ -15410,7 +15568,8 @@ var en_default2 = {
15410
15568
  },
15411
15569
  stripeLink: {
15412
15570
  title: "Pay with Link",
15413
- subtitle: "Buy with card or bank"
15571
+ subtitle: "Buy with card or bank",
15572
+ unavailableInRegionMessage: "Pay with Link is currently unavailable in your region."
15414
15573
  },
15415
15574
  browserWallet: {
15416
15575
  title: "Connect Wallet",
@@ -16576,13 +16735,25 @@ function BuyWithCard({
16576
16735
  wallets: externalWallets,
16577
16736
  assetCdnUrl,
16578
16737
  hideDepositFlowInfo = false,
16579
- hideDisplayDescription = false
16738
+ hideDisplayDescription = false,
16739
+ prefilledAmountUsd
16580
16740
  }) {
16581
16741
  const { colors: colors2, fonts, components } = useTheme();
16582
- const [amount, setAmount] = (0, import_react9.useState)("");
16742
+ const cleanedPrefilledAmountUsd = React52.useMemo(() => {
16743
+ if (!prefilledAmountUsd) return "";
16744
+ return prefilledAmountUsd.replace(/[^0-9.]/g, "");
16745
+ }, [prefilledAmountUsd]);
16746
+ const parsedPrefilledAmountUsd = React52.useMemo(() => {
16747
+ const parsed = parseFloat(cleanedPrefilledAmountUsd);
16748
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
16749
+ }, [cleanedPrefilledAmountUsd]);
16750
+ const shouldAutoConvertPrefilledRef = (0, import_react9.useRef)(!!cleanedPrefilledAmountUsd);
16751
+ const [amount, setAmount] = (0, import_react9.useState)(() => cleanedPrefilledAmountUsd);
16583
16752
  const [currency, setCurrency] = (0, import_react9.useState)("usd");
16584
16753
  const [hasManualCurrencySelection, setHasManualCurrencySelection] = (0, import_react9.useState)(false);
16585
- const [hasManualAmountEntry, setHasManualAmountEntry] = (0, import_react9.useState)(false);
16754
+ const [hasManualAmountEntry, setHasManualAmountEntry] = (0, import_react9.useState)(
16755
+ () => !!cleanedPrefilledAmountUsd
16756
+ );
16586
16757
  const [showCurrencyModal, setShowCurrencyModal] = (0, import_react9.useState)(false);
16587
16758
  const [quotes, setQuotes] = (0, import_react9.useState)([]);
16588
16759
  const [quotesLoading, setQuotesLoading] = (0, import_react9.useState)(false);
@@ -16639,6 +16810,71 @@ function BuyWithCard({
16639
16810
  const [preferredCurrencyCodes, setPreferredCurrencyCodes] = (0, import_react9.useState)([]);
16640
16811
  const [currenciesLoading, setCurrenciesLoading] = (0, import_react9.useState)(true);
16641
16812
  const [destinationToken, setDestinationToken] = (0, import_react9.useState)(null);
16813
+ (0, import_react9.useEffect)(() => {
16814
+ const hasPrefilledAmount = !!cleanedPrefilledAmountUsd;
16815
+ shouldAutoConvertPrefilledRef.current = hasPrefilledAmount;
16816
+ if (!hasPrefilledAmount) return;
16817
+ setAmount(cleanedPrefilledAmountUsd);
16818
+ setHasManualAmountEntry(true);
16819
+ }, [cleanedPrefilledAmountUsd]);
16820
+ const { data: fiatExchangeRatesResponse, isLoading: isFiatExchangeRatesLoading } = (0, import_react_query3.useQuery)({
16821
+ queryKey: ["fiat-exchange-rates", publishableKey],
16822
+ staleTime: 3e4,
16823
+ refetchInterval: 3e4,
16824
+ queryFn: async () => {
16825
+ try {
16826
+ return await getFiatExchangeRates({}, publishableKey);
16827
+ } catch (error) {
16828
+ console.error("Error fetching fiat exchange rates:", error);
16829
+ return { base_currency: "usd", rates: {} };
16830
+ }
16831
+ }
16832
+ });
16833
+ const fiatExchangeRates = fiatExchangeRatesResponse?.rates ?? {};
16834
+ const convertAmountBetweenCurrencies = React52.useCallback(
16835
+ (rawAmount, fromCurrencyCode, toCurrencyCode) => {
16836
+ const parsedAmount = parseFloat(rawAmount);
16837
+ if (!Number.isFinite(parsedAmount) || parsedAmount <= 0) return null;
16838
+ const fromCode = fromCurrencyCode.toLowerCase();
16839
+ const toCode = toCurrencyCode.toLowerCase();
16840
+ const fromRate = fromCode === "usd" ? 1 : fiatExchangeRates[fromCode];
16841
+ const toRate = toCode === "usd" ? 1 : fiatExchangeRates[toCode];
16842
+ if (!Number.isFinite(fromRate) || fromRate <= 0) return null;
16843
+ if (!Number.isFinite(toRate) || toRate <= 0) return null;
16844
+ const usdAmount = parsedAmount / fromRate;
16845
+ return parseFloat((usdAmount * toRate).toFixed(2)).toString();
16846
+ },
16847
+ [fiatExchangeRates]
16848
+ );
16849
+ const getConvertedPrefilledAmount = React52.useCallback(
16850
+ (targetCurrencyCode) => {
16851
+ if (!parsedPrefilledAmountUsd) return null;
16852
+ const normalizedTargetCurrency = targetCurrencyCode.toLowerCase();
16853
+ const rate = normalizedTargetCurrency === "usd" ? 1 : fiatExchangeRates[normalizedTargetCurrency];
16854
+ if (!Number.isFinite(rate) || rate <= 0) return null;
16855
+ return parseFloat((parsedPrefilledAmountUsd * rate).toFixed(2)).toString();
16856
+ },
16857
+ [parsedPrefilledAmountUsd, fiatExchangeRates]
16858
+ );
16859
+ (0, import_react9.useEffect)(() => {
16860
+ if (!cleanedPrefilledAmountUsd || !shouldAutoConvertPrefilledRef.current) return;
16861
+ const convertedAmount = getConvertedPrefilledAmount(currency);
16862
+ if (!convertedAmount) {
16863
+ if (isFiatExchangeRatesLoading) return;
16864
+ const targetCurrency = currency.toLowerCase();
16865
+ if (targetCurrency !== "usd") {
16866
+ setCurrency("usd");
16867
+ }
16868
+ return;
16869
+ }
16870
+ setAmount(convertedAmount);
16871
+ setHasManualAmountEntry(true);
16872
+ }, [
16873
+ cleanedPrefilledAmountUsd,
16874
+ currency,
16875
+ getConvertedPrefilledAmount,
16876
+ isFiatExchangeRatesLoading
16877
+ ]);
16642
16878
  const depositWalletId = defaultToken ? getWalletByChainType(wallets, defaultToken.destination_token_metadata.chain_type)?.id : void 0;
16643
16879
  const { executions, isPolling, showWaitingUi } = useDepositPolling({
16644
16880
  userId,
@@ -16669,6 +16905,7 @@ function BuyWithCard({
16669
16905
  }, [publishableKey]);
16670
16906
  (0, import_react9.useEffect)(() => {
16671
16907
  if (hasManualCurrencySelection) return;
16908
+ if (hasManualAmountEntry && !shouldAutoConvertPrefilledRef.current) return;
16672
16909
  if (fiatCurrencies.length === 0 || !userIpInfo?.alpha2) return;
16673
16910
  const userCountryCode = userIpInfo.alpha2;
16674
16911
  const matchingCurrency = fiatCurrencies.find((c) => c.country_codes.includes(userCountryCode));
@@ -16687,7 +16924,15 @@ function BuyWithCard({
16687
16924
  const prevCurrencyRef = (0, import_react9.useRef)(null);
16688
16925
  (0, import_react9.useEffect)(() => {
16689
16926
  if (fiatCurrencies.length === 0) return;
16927
+ if (shouldAutoConvertPrefilledRef.current) {
16928
+ prevCurrencyRef.current = currency;
16929
+ return;
16930
+ }
16690
16931
  if (prevCurrencyRef.current !== null && prevCurrencyRef.current !== currency) {
16932
+ if (hasManualAmountEntry) {
16933
+ prevCurrencyRef.current = currency;
16934
+ return;
16935
+ }
16691
16936
  const currentCurrency = fiatCurrencies.find(
16692
16937
  (c) => c.currency_code.toLowerCase() === currency.toLowerCase()
16693
16938
  );
@@ -16696,7 +16941,7 @@ function BuyWithCard({
16696
16941
  }
16697
16942
  }
16698
16943
  prevCurrencyRef.current = currency;
16699
- }, [currency]);
16944
+ }, [currency, fiatCurrencies, hasManualAmountEntry]);
16700
16945
  (0, import_react9.useEffect)(() => {
16701
16946
  async function fetchDestinationToken() {
16702
16947
  try {
@@ -16873,6 +17118,7 @@ function BuyWithCard({
16873
17118
  return () => clearInterval(timer);
16874
17119
  }, [quotes.length, amount]);
16875
17120
  const handleAmountChange = (value) => {
17121
+ shouldAutoConvertPrefilledRef.current = false;
16876
17122
  if (value === "") {
16877
17123
  setAmount(value);
16878
17124
  setHasManualAmountEntry(true);
@@ -16886,6 +17132,7 @@ function BuyWithCard({
16886
17132
  }
16887
17133
  };
16888
17134
  const handleQuickAmount = (quickAmount) => {
17135
+ shouldAutoConvertPrefilledRef.current = false;
16889
17136
  setAmount(quickAmount.toString());
16890
17137
  setHasManualAmountEntry(true);
16891
17138
  };
@@ -17489,8 +17736,43 @@ function BuyWithCard({
17489
17736
  preferredCurrencyCodes,
17490
17737
  selectedCurrency: currency,
17491
17738
  onSelectCurrency: (currencyCode) => {
17492
- setCurrency(currencyCode.toLowerCase());
17739
+ const nextCurrency = currencyCode.toLowerCase();
17740
+ if (nextCurrency === currency.toLowerCase()) {
17741
+ setHasManualCurrencySelection(true);
17742
+ return;
17743
+ }
17744
+ const currentCurrency = currency;
17493
17745
  setHasManualCurrencySelection(true);
17746
+ if (shouldAutoConvertPrefilledRef.current) {
17747
+ const convertedAmount = getConvertedPrefilledAmount(nextCurrency);
17748
+ if (convertedAmount) {
17749
+ setCurrency(nextCurrency);
17750
+ setAmount(convertedAmount);
17751
+ setHasManualAmountEntry(true);
17752
+ } else {
17753
+ if (isFiatExchangeRatesLoading) return;
17754
+ const fallbackUsdAmount = getConvertedPrefilledAmount("usd");
17755
+ setCurrency("usd");
17756
+ if (fallbackUsdAmount) {
17757
+ setAmount(fallbackUsdAmount);
17758
+ setHasManualAmountEntry(true);
17759
+ }
17760
+ }
17761
+ return;
17762
+ }
17763
+ if (hasManualAmountEntry && amount) {
17764
+ const convertedAmount = convertAmountBetweenCurrencies(
17765
+ amount,
17766
+ currentCurrency,
17767
+ nextCurrency
17768
+ );
17769
+ if (convertedAmount) {
17770
+ setCurrency(nextCurrency);
17771
+ setAmount(convertedAmount);
17772
+ }
17773
+ return;
17774
+ }
17775
+ setCurrency(nextCurrency);
17494
17776
  },
17495
17777
  themeClass
17496
17778
  }
@@ -17543,7 +17825,7 @@ function useCoinbaseLegalAgreements({
17543
17825
  publishableKey,
17544
17826
  enabled = true
17545
17827
  }) {
17546
- return (0, import_react_query5.useQuery)({
17828
+ return (0, import_react_query6.useQuery)({
17547
17829
  queryKey: ["unifold", "coinbaseLegalAgreements", publishableKey],
17548
17830
  queryFn: () => getCoinbaseLegalAgreements(publishableKey),
17549
17831
  enabled: enabled && !!publishableKey,
@@ -17561,7 +17843,7 @@ function useApplePayLimits({
17561
17843
  enabled = true
17562
17844
  }) {
17563
17845
  const phoneValid = US_E164_REGEX.test(phone);
17564
- return (0, import_react_query6.useQuery)({
17846
+ return (0, import_react_query7.useQuery)({
17565
17847
  queryKey: ["unifold", "applePayLimits", phone, publishableKey],
17566
17848
  queryFn: ({ signal }) => getCoinbaseApplePayLimits(phone, publishableKey, signal),
17567
17849
  enabled: enabled && phoneValid && !!publishableKey,
@@ -17661,7 +17943,7 @@ function useDefaultOnrampToken({
17661
17943
  isLoading,
17662
17944
  isError,
17663
17945
  error
17664
- } = (0, import_react_query7.useQuery)({
17946
+ } = (0, import_react_query8.useQuery)({
17665
17947
  queryKey: [
17666
17948
  "unifold",
17667
17949
  "defaultOnrampToken",
@@ -17735,7 +18017,7 @@ function parseCoinbasePostMessage(raw) {
17735
18017
  } : void 0
17736
18018
  };
17737
18019
  }
17738
- var BuyWithApplePay = React52.forwardRef(
18020
+ var BuyWithApplePay = React62.forwardRef(
17739
18021
  function BuyWithApplePay2({
17740
18022
  userId,
17741
18023
  publishableKey,
@@ -17894,7 +18176,7 @@ var BuyWithApplePay = React52.forwardRef(
17894
18176
  popupRef.current = null;
17895
18177
  };
17896
18178
  }, []);
17897
- React52.useImperativeHandle(
18179
+ React62.useImperativeHandle(
17898
18180
  ref,
17899
18181
  () => ({
17900
18182
  requestBack: () => {
@@ -19204,7 +19486,7 @@ function LegalDisclaimer({ legalAgreements, loading }) {
19204
19486
  children: [
19205
19487
  "By continuing, you agree to Coinbase's",
19206
19488
  " ",
19207
- agreements.map((a, idx, arr) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(React52.Fragment, { children: [
19489
+ agreements.map((a, idx, arr) => /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(React62.Fragment, { children: [
19208
19490
  /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
19209
19491
  "a",
19210
19492
  {
@@ -19620,7 +19902,7 @@ function useIsMobileViewport() {
19620
19902
  return isMobile;
19621
19903
  }
19622
19904
  function useCashAppLimits({ publishableKey, currency = "usd" }) {
19623
- return (0, import_react_query8.useQuery)({
19905
+ return (0, import_react_query9.useQuery)({
19624
19906
  queryKey: ["unifold", "cashAppLimits", currency, publishableKey],
19625
19907
  queryFn: () => getCashAppLimits(currency, publishableKey),
19626
19908
  enabled: !!publishableKey,
@@ -19633,6 +19915,7 @@ var POLL_INTERVAL_MS2 = 5e3;
19633
19915
  var FALLBACK_MIN_USD = 5;
19634
19916
  var SUGGESTED_AMOUNTS = [25, 50, 100];
19635
19917
  var t3 = i18n2.depositModal.cashApp;
19918
+ var sanitizePrefilledUsd = (value) => value?.replace(/[^0-9.]/g, "") ?? "";
19636
19919
  function PayWithCashApp({
19637
19920
  userId,
19638
19921
  publishableKey,
@@ -19647,6 +19930,7 @@ function PayWithCashApp({
19647
19930
  onEvent,
19648
19931
  onDepositSuccess,
19649
19932
  onDepositError,
19933
+ prefilledAmountUsd,
19650
19934
  wallets = []
19651
19935
  }) {
19652
19936
  const { colors: colors2, fonts, components } = useTheme();
@@ -19662,7 +19946,7 @@ function PayWithCashApp({
19662
19946
  const { data: limits, isLoading: limitsLoading } = useCashAppLimits({ publishableKey });
19663
19947
  const minUsd = limits?.minimum_amount ?? FALLBACK_MIN_USD;
19664
19948
  const maxUsd = limits?.maximum_amount ?? null;
19665
- const [amount, setAmount] = (0, import_react20.useState)("");
19949
+ const [amount, setAmount] = (0, import_react20.useState)(() => sanitizePrefilledUsd(prefilledAmountUsd));
19666
19950
  const [loading, setLoading] = (0, import_react20.useState)(false);
19667
19951
  const [session, setSession] = (0, import_react20.useState)(null);
19668
19952
  const [status, setStatus] = (0, import_react20.useState)("pending");
@@ -19785,6 +20069,13 @@ function PayWithCashApp({
19785
20069
  return () => clearInterval(interval);
19786
20070
  }, [session, view, status, publishableKey, onDepositSuccess, onDepositError]);
19787
20071
  const [softExpired, setSoftExpired] = (0, import_react20.useState)(false);
20072
+ (0, import_react20.useEffect)(() => {
20073
+ if (!prefilledAmountUsd) return;
20074
+ const cleaned = sanitizePrefilledUsd(prefilledAmountUsd);
20075
+ if (!cleaned) return;
20076
+ setAmount(cleaned);
20077
+ onAmountChange?.(cleaned);
20078
+ }, [prefilledAmountUsd, onAmountChange]);
19788
20079
  (0, import_react20.useEffect)(() => {
19789
20080
  if (!session?.expires_at || view !== "payment") return;
19790
20081
  const expiresMs = new Date(session.expires_at).getTime();
@@ -20139,7 +20430,7 @@ function useBankTransferProviders({
20139
20430
  countryCode
20140
20431
  }) {
20141
20432
  const normalizedCountry = countryCode?.toUpperCase();
20142
- const { data: providers, isLoading } = (0, import_react_query9.useQuery)({
20433
+ const { data: providers, isLoading } = (0, import_react_query10.useQuery)({
20143
20434
  queryKey: ["unifold", "bankTransferProviders", publishableKey, normalizedCountry ?? null],
20144
20435
  queryFn: () => getBankTransferProviders(publishableKey, { countryCode: normalizedCountry }),
20145
20436
  enabled,
@@ -20177,7 +20468,8 @@ function BankTransfer({
20177
20468
  assetCdnUrl,
20178
20469
  onDepositSuccess,
20179
20470
  onEvent,
20180
- onDepositError
20471
+ onDepositError,
20472
+ prefilledAmountUsd
20181
20473
  }) {
20182
20474
  const { colors: colors2, fonts, components } = useTheme();
20183
20475
  const [internalView, setInternalView] = (0, import_react23.useState)("providers");
@@ -20187,6 +20479,10 @@ function BankTransfer({
20187
20479
  const [requestBase, setRequestBase] = (0, import_react23.useState)(null);
20188
20480
  const [activeRequest, setActiveRequest] = (0, import_react23.useState)(null);
20189
20481
  const [amount, setAmount] = (0, import_react23.useState)("");
20482
+ const [fiatExchangeRates, setFiatExchangeRates] = (0, import_react23.useState)({
20483
+ usd: 1
20484
+ });
20485
+ const providerSelectionRequestIdRef = (0, import_react23.useRef)(0);
20190
20486
  const currentView = externalView ?? internalView;
20191
20487
  const setView = (v) => {
20192
20488
  setInternalView(v);
@@ -20236,7 +20532,38 @@ function BankTransfer({
20236
20532
  () => destinationTokenSymbol?.toUpperCase() ?? defaultToken?.destination_token_metadata?.symbol?.toUpperCase() ?? defaultToken?.destination_currency?.toUpperCase() ?? "USDC",
20237
20533
  [destinationTokenSymbol, defaultToken]
20238
20534
  );
20239
- const handleProviderClick = (provider) => {
20535
+ const resolvePrefilledSourceAmount = (0, import_react23.useCallback)(
20536
+ async (sourceCurrencyCode) => {
20537
+ const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
20538
+ if (!cleanedPrefilled) return "";
20539
+ const prefilledUsd = parseFloat(cleanedPrefilled);
20540
+ if (!Number.isFinite(prefilledUsd) || prefilledUsd <= 0) return "";
20541
+ const sourceCurrency2 = sourceCurrencyCode.toLowerCase();
20542
+ let rate = sourceCurrency2 === "usd" ? 1 : fiatExchangeRates[sourceCurrency2];
20543
+ if ((!rate || rate <= 0) && sourceCurrency2 !== "usd") {
20544
+ try {
20545
+ const response = await getFiatExchangeRates({}, publishableKey);
20546
+ if (response?.rates) {
20547
+ setFiatExchangeRates((prev) => ({
20548
+ ...prev,
20549
+ ...response.rates,
20550
+ usd: 1
20551
+ }));
20552
+ }
20553
+ const fetchedRate = response.rates?.[sourceCurrency2];
20554
+ if (Number.isFinite(fetchedRate) && fetchedRate > 0) {
20555
+ rate = fetchedRate;
20556
+ }
20557
+ } catch (error) {
20558
+ console.error("Error fetching fiat exchange rates for bank transfer:", error);
20559
+ }
20560
+ }
20561
+ if (!rate || rate <= 0) return sourceCurrency2 === "usd" ? cleanedPrefilled : "";
20562
+ return parseFloat((prefilledUsd * rate).toFixed(2)).toString();
20563
+ },
20564
+ [fiatExchangeRates, prefilledAmountUsd, publishableKey]
20565
+ );
20566
+ const handleProviderClick = async (provider) => {
20240
20567
  if (!provider.enabled) return;
20241
20568
  setSessionError(null);
20242
20569
  if (!defaultToken) {
@@ -20255,6 +20582,7 @@ function BankTransfer({
20255
20582
  });
20256
20583
  return;
20257
20584
  }
20585
+ const requestId = ++providerSelectionRequestIdRef.current;
20258
20586
  setRequestBase({
20259
20587
  service_provider: provider.service_provider,
20260
20588
  country_code: (userIpInfo?.alpha2 || "DE").toUpperCase(),
@@ -20268,7 +20596,10 @@ function BankTransfer({
20268
20596
  payment_method: provider.payment_methods[0]
20269
20597
  });
20270
20598
  setActiveProvider(provider);
20271
- setAmount("100");
20599
+ const convertedPrefilled = await resolvePrefilledSourceAmount(provider.source_currency);
20600
+ if (requestId !== providerSelectionRequestIdRef.current) return;
20601
+ const hasPrefilledAmount = !!prefilledAmountUsd?.replace(/[^0-9.]/g, "");
20602
+ setAmount(hasPrefilledAmount ? convertedPrefilled : "100");
20272
20603
  setView("amount");
20273
20604
  };
20274
20605
  const handleAmountChange = (value) => {
@@ -20366,7 +20697,7 @@ function BankTransfer({
20366
20697
  return /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(
20367
20698
  "button",
20368
20699
  {
20369
- onClick: () => handleProviderClick(provider),
20700
+ onClick: () => void handleProviderClick(provider),
20370
20701
  onMouseEnter: () => !disabled && setHoveredId(provider.service_provider),
20371
20702
  onMouseLeave: () => setHoveredId(null),
20372
20703
  disabled,
@@ -20935,9 +21266,9 @@ function TransferCryptoButton({
20935
21266
  featuredTokens
20936
21267
  }) {
20937
21268
  const { colors: colors2, fonts, components } = useTheme();
20938
- const [isHovered, setIsHovered] = React62.useState(false);
20939
- const [isTouchDevice, setIsTouchDevice] = React62.useState(false);
20940
- React62.useEffect(() => {
21269
+ const [isHovered, setIsHovered] = React72.useState(false);
21270
+ const [isTouchDevice, setIsTouchDevice] = React72.useState(false);
21271
+ React72.useEffect(() => {
20941
21272
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
20942
21273
  }, []);
20943
21274
  const sortedTokens = featuredTokens ? [...featuredTokens].sort((a, b) => a.position - b.position) : [];
@@ -21017,9 +21348,9 @@ function DepositWithCardButton({
21017
21348
  paymentNetworks
21018
21349
  }) {
21019
21350
  const { colors: colors2, fonts, components } = useTheme();
21020
- const [isHovered, setIsHovered] = React72.useState(false);
21021
- const [isTouchDevice, setIsTouchDevice] = React72.useState(false);
21022
- React72.useEffect(() => {
21351
+ const [isHovered, setIsHovered] = React82.useState(false);
21352
+ const [isTouchDevice, setIsTouchDevice] = React82.useState(false);
21353
+ React82.useEffect(() => {
21023
21354
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21024
21355
  }, []);
21025
21356
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
@@ -21098,9 +21429,9 @@ function PayWithExchangeButton({
21098
21429
  loading = false
21099
21430
  }) {
21100
21431
  const { colors: colors2, fonts, components } = useTheme();
21101
- const [isHovered, setIsHovered] = React82.useState(false);
21102
- const [isTouchDevice, setIsTouchDevice] = React82.useState(false);
21103
- React82.useEffect(() => {
21432
+ const [isHovered, setIsHovered] = React92.useState(false);
21433
+ const [isTouchDevice, setIsTouchDevice] = React92.useState(false);
21434
+ React92.useEffect(() => {
21104
21435
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21105
21436
  }, []);
21106
21437
  if (loading) {
@@ -21202,11 +21533,11 @@ var buttonVariants = cva(
21202
21533
  }
21203
21534
  }
21204
21535
  );
21205
- var Button = React92.forwardRef(
21536
+ var Button = React102.forwardRef(
21206
21537
  ({ className, variant, size: size4, asChild = false, style, ...props }, ref) => {
21207
21538
  const Comp = asChild ? Slot2 : "button";
21208
21539
  const { components, fonts } = useTheme();
21209
- const themeStyle = React92.useMemo(() => {
21540
+ const themeStyle = React102.useMemo(() => {
21210
21541
  const baseStyle = { ...style };
21211
21542
  if (variant === "default" || !variant) {
21212
21543
  baseStyle.backgroundColor = components.button.primaryBackground;
@@ -21241,9 +21572,9 @@ function ConnectExchangeButton({
21241
21572
  connectedExchange
21242
21573
  }) {
21243
21574
  const { colors: colors2, fonts, components } = useTheme();
21244
- const [isHovered, setIsHovered] = React102.useState(false);
21245
- const [isTouchDevice, setIsTouchDevice] = React102.useState(false);
21246
- React102.useEffect(() => {
21575
+ const [isHovered, setIsHovered] = React112.useState(false);
21576
+ const [isTouchDevice, setIsTouchDevice] = React112.useState(false);
21577
+ React112.useEffect(() => {
21247
21578
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21248
21579
  }, []);
21249
21580
  const isConnected = connectedExchange != null;
@@ -21388,9 +21719,9 @@ function DepositTrackerButton({
21388
21719
  badge
21389
21720
  }) {
21390
21721
  const { colors: colors2, fonts, components } = useTheme();
21391
- const [isHovered, setIsHovered] = React112.useState(false);
21392
- const [isTouchDevice, setIsTouchDevice] = React112.useState(false);
21393
- React112.useEffect(() => {
21722
+ const [isHovered, setIsHovered] = React122.useState(false);
21723
+ const [isTouchDevice, setIsTouchDevice] = React122.useState(false);
21724
+ React122.useEffect(() => {
21394
21725
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21395
21726
  }, []);
21396
21727
  return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(
@@ -21461,9 +21792,9 @@ function DepositTrackerButton({
21461
21792
  }
21462
21793
  function CashAppButton({ onClick, title, subtitle, iconUrl }) {
21463
21794
  const { colors: colors2, fonts, components } = useTheme();
21464
- const [isHovered, setIsHovered] = React122.useState(false);
21465
- const [isTouchDevice, setIsTouchDevice] = React122.useState(false);
21466
- React122.useEffect(() => {
21795
+ const [isHovered, setIsHovered] = React132.useState(false);
21796
+ const [isTouchDevice, setIsTouchDevice] = React132.useState(false);
21797
+ React132.useEffect(() => {
21467
21798
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21468
21799
  }, []);
21469
21800
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)(
@@ -21545,11 +21876,11 @@ function AppleLogo({ className, style }) {
21545
21876
  }
21546
21877
  );
21547
21878
  }
21548
- function ApplePayButton({ onClick, title, subtitle }) {
21879
+ function ApplePayButton({ onClick, title, subtitle, iconUrl }) {
21549
21880
  const { colors: colors2, fonts, components } = useTheme();
21550
- const [isHovered, setIsHovered] = React132.useState(false);
21551
- const [isTouchDevice, setIsTouchDevice] = React132.useState(false);
21552
- React132.useEffect(() => {
21881
+ const [isHovered, setIsHovered] = React142.useState(false);
21882
+ const [isTouchDevice, setIsTouchDevice] = React142.useState(false);
21883
+ React142.useEffect(() => {
21553
21884
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21554
21885
  }, []);
21555
21886
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
@@ -21567,7 +21898,14 @@ function ApplePayButton({ onClick, title, subtitle }) {
21567
21898
  },
21568
21899
  children: [
21569
21900
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3", children: [
21570
- /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "uf-rounded-lg uf-p-2", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AppleLogo, { className: "uf-w-5 uf-h-5", style: { color: components.card.iconColor } }) }),
21901
+ /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "uf-rounded-lg uf-overflow-hidden uf-w-9 uf-h-9 uf-flex uf-items-center uf-justify-center", children: iconUrl ? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("img", { src: iconUrl, alt: "Apple Pay", width: 36, height: 36, className: "uf-rounded-lg" }) : /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
21902
+ "div",
21903
+ {
21904
+ className: "uf-w-9 uf-h-9 uf-rounded-lg uf-flex uf-items-center uf-justify-center",
21905
+ style: { backgroundColor: "#000" },
21906
+ children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(AppleLogo, { className: "uf-w-5 uf-h-5", style: { color: "#fff" } })
21907
+ }
21908
+ ) }),
21571
21909
  /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "uf-text-left", children: [
21572
21910
  /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
21573
21911
  "div",
@@ -21611,9 +21949,9 @@ function BankTransferButton({
21611
21949
  comingSoon = false
21612
21950
  }) {
21613
21951
  const { colors: colors2, fonts, components } = useTheme();
21614
- const [isHovered, setIsHovered] = React142.useState(false);
21615
- const [isTouchDevice, setIsTouchDevice] = React142.useState(false);
21616
- React142.useEffect(() => {
21952
+ const [isHovered, setIsHovered] = React152.useState(false);
21953
+ const [isTouchDevice, setIsTouchDevice] = React152.useState(false);
21954
+ React152.useEffect(() => {
21617
21955
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
21618
21956
  }, []);
21619
21957
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
@@ -21783,13 +22121,6 @@ function solanaCandidate(provider, type, name, icon) {
21783
22121
  if (provider.isConnected && provider.publicKey) {
21784
22122
  return { type, name, address: provider.publicKey.toString(), icon };
21785
22123
  }
21786
- try {
21787
- const resp = await provider.connect({ onlyIfTrusted: true });
21788
- if (resp.publicKey) {
21789
- return { type, name, address: resp.publicKey.toString(), icon };
21790
- }
21791
- } catch {
21792
- }
21793
22124
  return null;
21794
22125
  }
21795
22126
  };
@@ -21862,18 +22193,18 @@ async function detectConnectedBrowserWallet(chainType) {
21862
22193
  }
21863
22194
  function useDetectedBrowserWallet(opts = {}) {
21864
22195
  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);
22196
+ const [wallet, setWallet] = React162.useState(null);
22197
+ const [isLoading, setIsLoading] = React162.useState(enabled);
22198
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React162.useState(0);
22199
+ const onDisconnectRef = React162.useRef(onDisconnect);
21869
22200
  onDisconnectRef.current = onDisconnect;
21870
- React152.useEffect(() => {
22201
+ React162.useEffect(() => {
21871
22202
  const store = getEip6963Store();
21872
22203
  if (!store) return;
21873
22204
  setEip6963ProviderCount(store.getProviders().length);
21874
22205
  return store.subscribe((providers) => setEip6963ProviderCount(providers.length));
21875
22206
  }, []);
21876
- React152.useEffect(() => {
22207
+ React162.useEffect(() => {
21877
22208
  if (!enabled) {
21878
22209
  setWallet(null);
21879
22210
  setIsLoading(false);
@@ -22013,8 +22344,180 @@ async function disconnectInjectedBrowserWallet(wallet) {
22013
22344
  collectEthereumProvidersForDisconnect(window)
22014
22345
  );
22015
22346
  }
22347
+ var STORED_TYPE_TO_EIP6963_WALLET_ID = {
22348
+ metamask: "metamask",
22349
+ "phantom-ethereum": "phantom",
22350
+ coinbase: "coinbase",
22351
+ trust: "trust",
22352
+ rainbow: "rainbow",
22353
+ rabby: "rabby",
22354
+ okx: "okx"
22355
+ };
22356
+ var EIP6963_WALLET_ID_TO_INFO = {
22357
+ metamask: { walletType: "metamask", name: "MetaMask", icon: "metamask" },
22358
+ phantom: { walletType: "phantom-ethereum", name: "Phantom", icon: "phantom" },
22359
+ coinbase: { walletType: "coinbase", name: "Coinbase Wallet", icon: "coinbase" },
22360
+ trust: { walletType: "trust", name: "Trust Wallet", icon: "trust" },
22361
+ rainbow: { walletType: "rainbow", name: "Rainbow", icon: "rainbow" },
22362
+ rabby: { walletType: "rabby", name: "Rabby", icon: "rabby" },
22363
+ okx: { walletType: "okx", name: "OKX Wallet", icon: "okx" }
22364
+ };
22365
+ var WALLET_ID_TO_WALLET_TYPE = {
22366
+ phantom: "phantom-ethereum",
22367
+ coinbase: "coinbase",
22368
+ trust: "trust",
22369
+ rainbow: "rainbow",
22370
+ rabby: "rabby",
22371
+ okx: "okx",
22372
+ metamask: "metamask"
22373
+ };
22374
+ var WALLET_TYPE_TO_WALLET_ID = {
22375
+ "phantom-ethereum": "phantom",
22376
+ coinbase: "coinbase",
22377
+ trust: "trust",
22378
+ okx: "okx",
22379
+ rainbow: "rainbow",
22380
+ rabby: "rabby",
22381
+ metamask: "metamask"
22382
+ };
22383
+ function isWalletType(value) {
22384
+ return value === "phantom-solana" || value === "phantom-ethereum" || value === "metamask" || value === "coinbase" || value === "solflare" || value === "backpack" || value === "glow" || value === "trust" || value === "rainbow" || value === "rabby" || value === "okx";
22385
+ }
22386
+ function walletIdToWalletType(walletId) {
22387
+ return WALLET_ID_TO_WALLET_TYPE[walletId] || "metamask";
22388
+ }
22389
+ function walletTypeToWalletId(walletType) {
22390
+ return WALLET_TYPE_TO_WALLET_ID[walletType] || walletType;
22391
+ }
22392
+ function getLegacyEvmProviders(win) {
22393
+ if (!win) return {};
22394
+ const anyWin = win;
22395
+ return {
22396
+ ethereum: anyWin.ethereum,
22397
+ phantomEthereum: anyWin.phantom?.ethereum,
22398
+ coinbaseEthereum: anyWin.coinbaseWalletExtension,
22399
+ trustEthereum: anyWin.trustwallet?.ethereum,
22400
+ okxEthereum: anyWin.okxwallet
22401
+ };
22402
+ }
22403
+ function getInjectedSolanaProviders(win) {
22404
+ if (!win) return {};
22405
+ const anyWin = win;
22406
+ return {
22407
+ phantomSolana: anyWin.phantom?.solana,
22408
+ solflare: anyWin.solflare,
22409
+ backpack: anyWin.backpack,
22410
+ glow: anyWin.glow,
22411
+ coinbaseSolana: anyWin.coinbaseSolana || anyWin.coinbaseWalletExtension?.solana,
22412
+ trustSolana: anyWin.trustwallet?.solana
22413
+ };
22414
+ }
22415
+ function describeEip6963Provider(wp) {
22416
+ const mapped = EIP6963_WALLET_ID_TO_INFO[wp.walletId];
22417
+ return {
22418
+ provider: wp.provider,
22419
+ walletType: mapped?.walletType ?? "metamask",
22420
+ name: mapped?.name ?? wp.info.name,
22421
+ icon: mapped?.icon ?? wp.info.icon
22422
+ };
22423
+ }
22424
+ function resolveQuickConnectEvmProvider(win) {
22425
+ const eip6963Providers = getEip6963Providers();
22426
+ if (eip6963Providers.length > 0) {
22427
+ const stored = getStoredWalletState();
22428
+ const preferredWalletId = stored?.walletType && isWalletType(stored.walletType) ? STORED_TYPE_TO_EIP6963_WALLET_ID[stored.walletType] : void 0;
22429
+ if (preferredWalletId) {
22430
+ const preferred = findProviderByWalletId(preferredWalletId);
22431
+ if (preferred) return describeEip6963Provider(preferred);
22432
+ }
22433
+ if (eip6963Providers.length === 1) {
22434
+ return describeEip6963Provider(eip6963Providers[0]);
22435
+ }
22436
+ return void 0;
22437
+ }
22438
+ const anyWin = win;
22439
+ const legacy = anyWin.phantom?.ethereum || anyWin.ethereum;
22440
+ if (!legacy) return void 0;
22441
+ const isPhantom = legacy.isPhantom;
22442
+ return {
22443
+ provider: legacy,
22444
+ walletType: isPhantom ? "phantom-ethereum" : "metamask",
22445
+ name: isPhantom ? "Phantom" : "MetaMask",
22446
+ icon: isPhantom ? "phantom" : "metamask"
22447
+ };
22448
+ }
22449
+ function resolveSolanaPublicKey(provider, response) {
22450
+ if (response?.publicKey) return { publicKey: response.publicKey };
22451
+ if (provider.publicKey) return { publicKey: provider.publicKey };
22452
+ return null;
22453
+ }
22454
+ function isUserRejectedSolanaConnectError(error) {
22455
+ if (!error || typeof error !== "object") return false;
22456
+ const maybeCode = "code" in error ? error.code : void 0;
22457
+ if (maybeCode === 4001) return true;
22458
+ const msg = "message" in error && typeof error.message === "string" ? error.message.toLowerCase() : "";
22459
+ return msg.includes("user rejected") || msg.includes("user denied") || msg.includes("rejected the request") || msg.includes("declined");
22460
+ }
22461
+ function isSolanaConnectTimeoutError(error) {
22462
+ return error instanceof Error && error.message.toLowerCase().includes("did not respond to the connection request");
22463
+ }
22464
+ async function connectSolanaProviderWithRecovery(provider, walletId, walletName) {
22465
+ if (provider.isConnected && provider.publicKey) {
22466
+ return { publicKey: provider.publicKey };
22467
+ }
22468
+ const connectOnce = () => provider.connect(walletId === "solflare" ? { onlyIfTrusted: false } : void 0);
22469
+ const withTimeout = async (ms = 2e4) => await Promise.race([
22470
+ connectOnce(),
22471
+ new Promise(
22472
+ (resolve, reject) => setTimeout(() => {
22473
+ const connected = resolveSolanaPublicKey(provider);
22474
+ if (connected) {
22475
+ resolve(connected);
22476
+ return;
22477
+ }
22478
+ reject(
22479
+ new Error(
22480
+ `${walletName} did not respond to the connection request. Please unlock the wallet and try again.`
22481
+ )
22482
+ );
22483
+ }, ms)
22484
+ )
22485
+ ]);
22486
+ if (walletId === "solflare") {
22487
+ await provider.disconnect?.().catch(() => {
22488
+ });
22489
+ }
22490
+ const connectAndResolve = async () => {
22491
+ try {
22492
+ const response = await withTimeout();
22493
+ const resolved = resolveSolanaPublicKey(provider, response);
22494
+ if (resolved) return resolved;
22495
+ await new Promise((resolve) => setTimeout(resolve, 120));
22496
+ const delayedResolved = resolveSolanaPublicKey(provider);
22497
+ if (delayedResolved) return delayedResolved;
22498
+ throw new Error(`${walletName} connected but did not expose a public key.`);
22499
+ } catch (error) {
22500
+ const connected = resolveSolanaPublicKey(provider);
22501
+ if (connected) return connected;
22502
+ throw error;
22503
+ }
22504
+ };
22505
+ try {
22506
+ return await connectAndResolve();
22507
+ } catch (err) {
22508
+ if (isUserRejectedSolanaConnectError(err)) throw err;
22509
+ if (isSolanaConnectTimeoutError(err)) throw err;
22510
+ if (walletId === "solflare") {
22511
+ await provider.disconnect?.().catch(() => {
22512
+ });
22513
+ await new Promise((resolve) => setTimeout(resolve, 150));
22514
+ return await connectAndResolve();
22515
+ }
22516
+ throw err;
22517
+ }
22518
+ }
22016
22519
  function MetamaskIcon({ size: size4 = 24, className, variant = "color" }) {
22017
- const id = React162.useId();
22520
+ const id = React172.useId();
22018
22521
  if (variant === "light" || variant === "dark") {
22019
22522
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
22020
22523
  "svg",
@@ -22135,7 +22638,7 @@ function MetamaskIcon({ size: size4 = 24, className, variant = "color" }) {
22135
22638
  );
22136
22639
  }
22137
22640
  function PhantomIcon({ size: size4 = 24, className, variant = "color" }) {
22138
- const id = React172.useId();
22641
+ const id = React182.useId();
22139
22642
  if (variant === "light") {
22140
22643
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
22141
22644
  "svg",
@@ -22202,7 +22705,7 @@ function PhantomIcon({ size: size4 = 24, className, variant = "color" }) {
22202
22705
  );
22203
22706
  }
22204
22707
  function CoinbaseIcon({ size: size4 = 24, className, variant = "color" }) {
22205
- const id = React182.useId();
22708
+ const id = React192.useId();
22206
22709
  if (variant === "light") {
22207
22710
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
22208
22711
  "svg",
@@ -22282,7 +22785,7 @@ function CoinbaseIcon({ size: size4 = 24, className, variant = "color" }) {
22282
22785
  );
22283
22786
  }
22284
22787
  function RabbyIcon({ size: size4 = 24, className, variant = "color" }) {
22285
- const id = React192.useId();
22788
+ const id = React202.useId();
22286
22789
  if (variant === "light") {
22287
22790
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(
22288
22791
  "svg",
@@ -22629,7 +23132,7 @@ function RabbyIcon({ size: size4 = 24, className, variant = "color" }) {
22629
23132
  );
22630
23133
  }
22631
23134
  function RainbowIcon({ size: size4 = 24, className, variant = "color" }) {
22632
- const id = React202.useId();
23135
+ const id = React212.useId();
22633
23136
  if (variant === "light") {
22634
23137
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
22635
23138
  "svg",
@@ -23043,7 +23546,7 @@ function RainbowIcon({ size: size4 = 24, className, variant = "color" }) {
23043
23546
  );
23044
23547
  }
23045
23548
  function TrustIcon({ size: size4 = 24, className, variant = "color" }) {
23046
- const id = React212.useId();
23549
+ const id = React222.useId();
23047
23550
  if (variant === "light") {
23048
23551
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
23049
23552
  "svg",
@@ -23126,7 +23629,7 @@ function TrustIcon({ size: size4 = 24, className, variant = "color" }) {
23126
23629
  );
23127
23630
  }
23128
23631
  function OkxIcon({ size: size4 = 24, className, variant = "color" }) {
23129
- const id = React222.useId();
23632
+ const id = React232.useId();
23130
23633
  if (variant === "light") {
23131
23634
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
23132
23635
  "svg",
@@ -23181,7 +23684,7 @@ function OkxIcon({ size: size4 = 24, className, variant = "color" }) {
23181
23684
  );
23182
23685
  }
23183
23686
  function GlowIcon({ size: size4 = 24, className, variant = "color" }) {
23184
- const id = React232.useId();
23687
+ const id = React242.useId();
23185
23688
  if (variant === "light") {
23186
23689
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
23187
23690
  "svg",
@@ -23282,7 +23785,7 @@ function GlowIcon({ size: size4 = 24, className, variant = "color" }) {
23282
23785
  );
23283
23786
  }
23284
23787
  function BackpackIcon({ size: size4 = 24, className, variant = "color" }) {
23285
- const id = React242.useId();
23788
+ const id = React252.useId();
23286
23789
  if (variant === "light") {
23287
23790
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
23288
23791
  "svg",
@@ -23355,7 +23858,7 @@ function BackpackIcon({ size: size4 = 24, className, variant = "color" }) {
23355
23858
  );
23356
23859
  }
23357
23860
  function SolflareIcon({ size: size4 = 24, className, variant = "color" }) {
23358
- const id = React252.useId();
23861
+ const id = React262.useId();
23359
23862
  if (variant === "light") {
23360
23863
  return /* @__PURE__ */ (0, import_jsx_runtime54.jsx)(
23361
23864
  "svg",
@@ -23422,7 +23925,7 @@ function SolflareIcon({ size: size4 = 24, className, variant = "color" }) {
23422
23925
  );
23423
23926
  }
23424
23927
  function EthereumIcon({ size: size4 = 24, className, variant = "color" }) {
23425
- const id = React262.useId();
23928
+ const id = React272.useId();
23426
23929
  if (variant === "light") {
23427
23930
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
23428
23931
  "svg",
@@ -23546,7 +24049,7 @@ function EthereumIcon({ size: size4 = 24, className, variant = "color" }) {
23546
24049
  );
23547
24050
  }
23548
24051
  function SolanaIcon({ size: size4 = 24, className, variant = "color" }) {
23549
- const id = React272.useId();
24052
+ const id = React282.useId();
23550
24053
  if (variant === "light") {
23551
24054
  return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
23552
24055
  "svg",
@@ -23791,19 +24294,19 @@ function BrowserWalletButton({
23791
24294
  subtitle = i18n2.depositModal.browserWallet.subtitle
23792
24295
  }) {
23793
24296
  const { colors: colors2, fonts, components } = useTheme();
23794
- const [isHovered, setIsHovered] = React282.useState(false);
23795
- const [isTouchDevice, setIsTouchDevice] = React282.useState(false);
24297
+ const [isHovered, setIsHovered] = React292.useState(false);
24298
+ const [isTouchDevice, setIsTouchDevice] = React292.useState(false);
23796
24299
  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);
24300
+ const [isConnecting, setIsConnecting] = React292.useState(false);
24301
+ const [balanceText, setBalanceText] = React292.useState(null);
24302
+ const [isLoadingBalance, setIsLoadingBalance] = React292.useState(false);
24303
+ const [isDisconnecting, setIsDisconnecting] = React292.useState(false);
24304
+ const onDisconnectRef = React292.useRef(onDisconnect);
23802
24305
  onDisconnectRef.current = onDisconnect;
23803
- React282.useEffect(() => {
24306
+ React292.useEffect(() => {
23804
24307
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
23805
24308
  }, []);
23806
- React282.useEffect(() => {
24309
+ React292.useEffect(() => {
23807
24310
  if (!wallet || !publishableKey) {
23808
24311
  setBalanceText(null);
23809
24312
  return;
@@ -23872,21 +24375,19 @@ function BrowserWalletButton({
23872
24375
  }
23873
24376
  }
23874
24377
  if (!chainType || chainType === "ethereum") {
23875
- const ethProvider = window.phantom?.ethereum || window.ethereum;
23876
- if (ethProvider) {
23877
- const accounts = await ethProvider.request({
24378
+ const resolved = resolveQuickConnectEvmProvider(window);
24379
+ if (resolved) {
24380
+ const accounts = await resolved.provider.request({
23878
24381
  method: "eth_requestAccounts"
23879
24382
  });
23880
24383
  if (accounts && accounts.length > 0) {
23881
24384
  setUserDisconnectedWallet(false);
23882
- const isPhantom = ethProvider.isPhantom;
23883
- const walletType = isPhantom ? "phantom-ethereum" : "metamask";
23884
- setStoredWalletState(walletType);
24385
+ setStoredWalletState(resolved.walletType);
23885
24386
  setWallet({
23886
- type: walletType,
23887
- name: isPhantom ? "Phantom" : "MetaMask",
24387
+ type: resolved.walletType,
24388
+ name: resolved.name,
23888
24389
  address: accounts[0],
23889
- icon: isPhantom ? "phantom" : "metamask"
24390
+ icon: resolved.icon
23890
24391
  });
23891
24392
  }
23892
24393
  }
@@ -23920,7 +24421,10 @@ function BrowserWalletButton({
23920
24421
  if (isLoading) {
23921
24422
  return null;
23922
24423
  }
23923
- const hasWalletExtension = (!chainType || chainType === "ethereum") && getEip6963Providers().length > 0 || (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) || (!chainType || chainType === "ethereum") && (window.phantom?.ethereum || window.ethereum);
24424
+ const eip6963EvmProviderCount = getEip6963Providers().length;
24425
+ const legacyEvmProviders = getLegacyEvmProviders(window);
24426
+ const hasLegacyEvmProvider = eip6963EvmProviderCount === 0 && !!(legacyEvmProviders.ethereum || legacyEvmProviders.phantomEthereum || legacyEvmProviders.coinbaseEthereum || legacyEvmProviders.trustEthereum || legacyEvmProviders.okxEthereum);
24427
+ const hasWalletExtension = (!chainType || chainType === "ethereum") && eip6963EvmProviderCount > 0 || (!chainType || chainType === "solana") && (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) || (!chainType || chainType === "ethereum") && hasLegacyEvmProvider;
23924
24428
  if (!onConnectClick && !wallet && !hasWalletExtension) {
23925
24429
  return null;
23926
24430
  }
@@ -23930,11 +24434,25 @@ function BrowserWalletButton({
23930
24434
  border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
23931
24435
  };
23932
24436
  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], {
24437
+ const isImageIcon = !!wallet && (wallet.icon.startsWith("data:") || wallet.icon.startsWith("http"));
24438
+ const walletIconBlock = wallet ? WALLET_ICON_COMPONENTS[wallet.icon] ? React292.createElement(WALLET_ICON_COMPONENTS[wallet.icon], {
23934
24439
  size: 36,
23935
24440
  className: "uf-rounded-lg",
23936
24441
  variant: "color"
23937
- }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "uf-w-9 uf-h-9 uf-rounded-lg uf-bg-gray-500" }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "uf-rounded-lg uf-p-2", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Wallet, { className: "uf-w-5 uf-h-5", style: { color: components.card.iconColor } }) });
24442
+ }) : isImageIcon ? (
24443
+ // Wallet announced via EIP-6963 with no internal icon component: render its
24444
+ // own advertised icon (`info.icon`) rather than a generic placeholder.
24445
+ /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
24446
+ "img",
24447
+ {
24448
+ src: wallet.icon,
24449
+ alt: wallet.name,
24450
+ width: 36,
24451
+ height: 36,
24452
+ className: "uf-rounded-lg uf-w-9 uf-h-9"
24453
+ }
24454
+ )
24455
+ ) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "uf-w-9 uf-h-9 uf-rounded-lg uf-bg-gray-500" }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "uf-rounded-lg uf-p-2", children: /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(Wallet, { className: "uf-w-5 uf-h-5", style: { color: components.card.iconColor } }) });
23938
24456
  const titleSubtitleBlock = /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "uf-text-left uf-min-w-0", children: [
23939
24457
  /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(
23940
24458
  "div",
@@ -24081,9 +24599,9 @@ function StripeLinkButton({
24081
24599
  iconUrl
24082
24600
  }) {
24083
24601
  const { colors: colors2, fonts, components } = useTheme();
24084
- const [isHovered, setIsHovered] = React292.useState(false);
24085
- const [isTouchDevice, setIsTouchDevice] = React292.useState(false);
24086
- React292.useEffect(() => {
24602
+ const [isHovered, setIsHovered] = React302.useState(false);
24603
+ const [isTouchDevice, setIsTouchDevice] = React302.useState(false);
24604
+ React302.useEffect(() => {
24087
24605
  setIsTouchDevice("ontouchstart" in window || navigator.maxTouchPoints > 0);
24088
24606
  }, []);
24089
24607
  return /* @__PURE__ */ (0, import_jsx_runtime59.jsxs)(
@@ -24569,6 +25087,8 @@ function PayWithStripeLink({
24569
25087
  destinationChainType,
24570
25088
  destinationChainId,
24571
25089
  destinationTokenAddress,
25090
+ countryCode,
25091
+ subdivisionCode,
24572
25092
  wallets: externalWallets,
24573
25093
  email: emailProp,
24574
25094
  iconUrl,
@@ -24963,7 +25483,9 @@ function PayWithStripeLink({
24963
25483
  {
24964
25484
  tokenAddress: destinationTokenAddress,
24965
25485
  chainId: destinationChainId,
24966
- chainType: destinationChainType
25486
+ chainType: destinationChainType,
25487
+ countryCode,
25488
+ subdivisionCode
24967
25489
  },
24968
25490
  publishableKey
24969
25491
  ).then((token) => {
@@ -24982,7 +25504,14 @@ function PayWithStripeLink({
24982
25504
  return () => {
24983
25505
  cancelled = true;
24984
25506
  };
24985
- }, [publishableKey, destinationTokenAddress, destinationChainId, destinationChainType]);
25507
+ }, [
25508
+ publishableKey,
25509
+ destinationTokenAddress,
25510
+ destinationChainId,
25511
+ destinationChainType,
25512
+ countryCode,
25513
+ subdivisionCode
25514
+ ]);
24986
25515
  const destinationCurrency = stripeDestCurrency;
24987
25516
  const authInnerRef = (0, import_react24.useRef)(null);
24988
25517
  const paymentInnerRef = (0, import_react24.useRef)(null);
@@ -27840,7 +28369,7 @@ function useProjectConfig({
27840
28369
  data: projectConfig,
27841
28370
  isLoading,
27842
28371
  error
27843
- } = (0, import_react_query10.useQuery)({
28372
+ } = (0, import_react_query11.useQuery)({
27844
28373
  // Country is part of the key so a region change refetches the region-aware
27845
28374
  // config. Omitted when undefined so callers that don't pass a country keep
27846
28375
  // sharing the base cache entry.
@@ -27850,7 +28379,7 @@ function useProjectConfig({
27850
28379
  // Keep the previous (e.g. no-country) config visible while the region-aware
27851
28380
  // config refetches after the country resolves, so unrelated config-driven
27852
28381
  // UI doesn't flash back to defaults.
27853
- placeholderData: import_react_query10.keepPreviousData,
28382
+ placeholderData: import_react_query11.keepPreviousData,
27854
28383
  staleTime: 1e3 * 60 * 30,
27855
28384
  refetchOnMount: true,
27856
28385
  refetchOnWindowFocus: true
@@ -27868,7 +28397,7 @@ function useSupportedDepositTokens(publishableKey, options) {
27868
28397
  ...options?.product_type ? { product_type: options.product_type } : {}
27869
28398
  };
27870
28399
  const hasFilteredOptions = Object.keys(filteredOptions).length > 0;
27871
- return (0, import_react_query11.useQuery)({
28400
+ return (0, import_react_query12.useQuery)({
27872
28401
  queryKey: [
27873
28402
  "unifold",
27874
28403
  "supportedDepositTokens",
@@ -27892,7 +28421,7 @@ function useIntegrationTransferDefaultToken({
27892
28421
  publishableKey,
27893
28422
  enabled = true
27894
28423
  }) {
27895
- return (0, import_react_query12.useQuery)({
28424
+ return (0, import_react_query13.useQuery)({
27896
28425
  queryKey: [
27897
28426
  "unifold",
27898
28427
  "integrationTransferDefaultToken",
@@ -27958,7 +28487,8 @@ function CoinbaseConnect({
27958
28487
  defaultSourceChainType,
27959
28488
  defaultSourceChainId,
27960
28489
  defaultSourceTokenAddress,
27961
- defaultSourceSymbol
28490
+ defaultSourceSymbol,
28491
+ prefilledAmountUsd
27962
28492
  }) {
27963
28493
  const { colors: colors2, fonts, components } = useTheme();
27964
28494
  const { projectConfig } = useProjectConfig({ publishableKey });
@@ -28281,7 +28811,8 @@ function CoinbaseConnect({
28281
28811
  };
28282
28812
  const handleSelectAsset = (asset) => {
28283
28813
  setSelectedAsset(asset);
28284
- setSendAmount("");
28814
+ const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
28815
+ setSendAmount(cleanedPrefilled);
28285
28816
  transitionTo("enter_amount");
28286
28817
  };
28287
28818
  const handleCreateTransfer = async () => {
@@ -29869,7 +30400,7 @@ function useExchanges({
29869
30400
  publishableKey,
29870
30401
  enabled = true
29871
30402
  }) {
29872
- const { data: exchanges = [], isLoading } = (0, import_react_query13.useQuery)({
30403
+ const { data: exchanges = [], isLoading } = (0, import_react_query14.useQuery)({
29873
30404
  queryKey: ["unifold", "exchanges", publishableKey],
29874
30405
  queryFn: () => getExchanges(void 0, publishableKey).then((res) => res.data),
29875
30406
  enabled,
@@ -29879,11 +30410,29 @@ function useExchanges({
29879
30410
  });
29880
30411
  return { exchanges, isLoading };
29881
30412
  }
30413
+ function usePublicIncident({
30414
+ publishableKey,
30415
+ enabled = true
30416
+ }) {
30417
+ const {
30418
+ data: incident,
30419
+ isLoading,
30420
+ error
30421
+ } = (0, import_react_query15.useQuery)({
30422
+ queryKey: ["unifold", "publicIncident", publishableKey],
30423
+ queryFn: () => getPublicIncident(publishableKey),
30424
+ enabled,
30425
+ staleTime: 1e3 * 30,
30426
+ refetchInterval: 1e3 * 30,
30427
+ refetchOnWindowFocus: true
30428
+ });
30429
+ return { incident, isLoading, error: error ?? null };
30430
+ }
29882
30431
  function useApplePayProviders({
29883
30432
  publishableKey,
29884
30433
  enabled = true
29885
30434
  }) {
29886
- const { data: providers, isLoading } = (0, import_react_query14.useQuery)({
30435
+ const { data: providers, isLoading } = (0, import_react_query16.useQuery)({
29887
30436
  queryKey: ["unifold", "applePayProviders", publishableKey],
29888
30437
  queryFn: () => getApplePayProviders(publishableKey),
29889
30438
  enabled,
@@ -29943,7 +30492,7 @@ function useAddressValidation({
29943
30492
  refetchOnMount = false
29944
30493
  }) {
29945
30494
  const shouldValidate = enabled && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
29946
- const { data, isLoading, error } = (0, import_react_query15.useQuery)({
30495
+ const { data, isLoading, error } = (0, import_react_query17.useQuery)({
29947
30496
  queryKey: [
29948
30497
  "unifold",
29949
30498
  "addressValidation",
@@ -29974,6 +30523,7 @@ function useAddressValidation({
29974
30523
  return {
29975
30524
  isValid: null,
29976
30525
  failureCode: null,
30526
+ message: null,
29977
30527
  metadata: null,
29978
30528
  isLoading: false,
29979
30529
  error: null
@@ -29982,6 +30532,7 @@ function useAddressValidation({
29982
30532
  return {
29983
30533
  isValid: data?.valid ?? null,
29984
30534
  failureCode: data?.failure_code ?? null,
30535
+ message: data?.message ?? null,
29985
30536
  metadata: data?.metadata ?? null,
29986
30537
  isLoading,
29987
30538
  error: error ?? null
@@ -29992,7 +30543,7 @@ function ThemeStyleInjector({
29992
30543
  className
29993
30544
  }) {
29994
30545
  const { colors: colors2, fonts, mode } = useTheme();
29995
- const cssVars = React312.useMemo(() => {
30546
+ const cssVars = React322.useMemo(() => {
29996
30547
  const hexToHSL = (hex) => {
29997
30548
  hex = hex.replace("#", "");
29998
30549
  const r2 = parseInt(hex.slice(0, 2), 16) / 255;
@@ -30052,7 +30603,7 @@ function ThemeStyleInjector({
30052
30603
  ...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
30053
30604
  };
30054
30605
  }, [colors2, fonts.regular]);
30055
- React312.useEffect(() => {
30606
+ React322.useEffect(() => {
30056
30607
  if (typeof document === "undefined") return;
30057
30608
  if (fonts.regular) {
30058
30609
  document.documentElement.style.setProperty("--uf-font-family", fonts.regular);
@@ -30807,6 +31358,37 @@ function TokenSelectorSheet({
30807
31358
  var getChainKey = (chainId, chainType) => {
30808
31359
  return `${chainType}:${chainId}`;
30809
31360
  };
31361
+ function getStoredSelection(key) {
31362
+ if (typeof window === "undefined") return null;
31363
+ try {
31364
+ const raw = localStorage.getItem(key);
31365
+ if (!raw) return null;
31366
+ const parsed = JSON.parse(raw);
31367
+ if (parsed && typeof parsed.symbol === "string" && typeof parsed.chainType === "string" && typeof parsed.chainId === "string") {
31368
+ return parsed;
31369
+ }
31370
+ } catch {
31371
+ }
31372
+ return null;
31373
+ }
31374
+ function saveStoredSelection(key, symbol, chainType, chainId) {
31375
+ if (typeof window === "undefined") return;
31376
+ try {
31377
+ localStorage.setItem(key, JSON.stringify({ symbol, chainType, chainId }));
31378
+ } catch {
31379
+ }
31380
+ }
31381
+ function resolveFromStorage(tokens, stored) {
31382
+ for (const t13 of tokens) {
31383
+ if (t13.symbol !== stored.symbol) continue;
31384
+ const matchedChain = t13.chains.find(
31385
+ (c) => c.chain_type === stored.chainType && c.chain_id === stored.chainId
31386
+ );
31387
+ if (matchedChain) return { token: t13, chain: matchedChain };
31388
+ if (t13.chains.length > 0) return { token: t13, chain: t13.chains[0] };
31389
+ }
31390
+ return null;
31391
+ }
30810
31392
  function resolveToken(tokens, defaultChainType, defaultChainId, defaultTokenAddress, defaultSymbol) {
30811
31393
  if (!tokens.length) return null;
30812
31394
  let selectedToken;
@@ -30856,27 +31438,73 @@ function useDefaultToken({
30856
31438
  defaultChainType,
30857
31439
  defaultChainId,
30858
31440
  defaultTokenAddress,
30859
- defaultSymbol
31441
+ defaultSymbol,
31442
+ storageKey: storageKey2
30860
31443
  }) {
30861
- const [token, setToken] = (0, import_react30.useState)(null);
30862
- const [chain, setChain] = (0, import_react30.useState)(null);
31444
+ const [token, setTokenState] = (0, import_react30.useState)(null);
31445
+ const [chain, setChainState] = (0, import_react30.useState)(null);
30863
31446
  const [initialSelectionDone, setInitialSelectionDone] = (0, import_react30.useState)(false);
30864
31447
  const appliedDefaultsRef = (0, import_react30.useRef)("");
31448
+ const tokenRef = (0, import_react30.useRef)(null);
31449
+ const chainRef = (0, import_react30.useRef)(null);
31450
+ tokenRef.current = token;
31451
+ chainRef.current = chain;
31452
+ const setToken = (0, import_react30.useCallback)(
31453
+ (newToken) => {
31454
+ tokenRef.current = newToken;
31455
+ setTokenState(newToken);
31456
+ if (storageKey2 && chainRef.current) {
31457
+ const [chainType, chainId] = chainRef.current.split(":");
31458
+ saveStoredSelection(storageKey2, newToken, chainType, chainId);
31459
+ }
31460
+ },
31461
+ [storageKey2]
31462
+ );
31463
+ const setChain = (0, import_react30.useCallback)(
31464
+ (newChain) => {
31465
+ chainRef.current = newChain;
31466
+ setChainState(newChain);
31467
+ if (storageKey2 && tokenRef.current) {
31468
+ const [chainType, chainId] = newChain.split(":");
31469
+ saveStoredSelection(storageKey2, tokenRef.current, chainType, chainId);
31470
+ }
31471
+ },
31472
+ [storageKey2]
31473
+ );
30865
31474
  (0, import_react30.useEffect)(() => {
30866
31475
  if (!tokens.length) return;
30867
31476
  const defaultsKey = `${defaultTokenAddress ?? ""}|${defaultSymbol ?? ""}|${defaultChainType ?? ""}|${defaultChainId ?? ""}`;
30868
31477
  const defaultsChanged = appliedDefaultsRef.current !== defaultsKey;
30869
31478
  if (initialSelectionDone && !defaultsChanged) return;
30870
- const result = resolveToken(
30871
- tokens,
30872
- defaultChainType,
30873
- defaultChainId,
30874
- defaultTokenAddress,
30875
- defaultSymbol
30876
- );
31479
+ const hasExplicitDefaults = defaultTokenAddress && defaultChainType && defaultChainId || defaultSymbol && defaultChainType && defaultChainId;
31480
+ let result = null;
31481
+ if (hasExplicitDefaults) {
31482
+ result = resolveToken(
31483
+ tokens,
31484
+ defaultChainType,
31485
+ defaultChainId,
31486
+ defaultTokenAddress,
31487
+ defaultSymbol
31488
+ );
31489
+ if (result) {
31490
+ const matched = defaultTokenAddress && result.chain.token_address.toLowerCase() === defaultTokenAddress.toLowerCase() && result.chain.chain_type === defaultChainType && result.chain.chain_id === defaultChainId || defaultSymbol && result.token.symbol === defaultSymbol && result.chain.chain_type === defaultChainType && result.chain.chain_id === defaultChainId;
31491
+ if (!matched) {
31492
+ result = null;
31493
+ }
31494
+ }
31495
+ }
31496
+ if (!result && storageKey2) {
31497
+ const stored = getStoredSelection(storageKey2);
31498
+ if (stored) {
31499
+ result = resolveFromStorage(tokens, stored);
31500
+ }
31501
+ }
31502
+ if (!result) {
31503
+ result = resolveToken(tokens);
31504
+ }
30877
31505
  if (result) {
30878
- setToken(result.token.symbol);
30879
- setChain(getChainKey(result.chain.chain_id, result.chain.chain_type));
31506
+ setTokenState(result.token.symbol);
31507
+ setChainState(getChainKey(result.chain.chain_id, result.chain.chain_type));
30880
31508
  appliedDefaultsRef.current = defaultsKey;
30881
31509
  setInitialSelectionDone(true);
30882
31510
  }
@@ -30886,7 +31514,8 @@ function useDefaultToken({
30886
31514
  defaultSymbol,
30887
31515
  defaultChainType,
30888
31516
  defaultChainId,
30889
- initialSelectionDone
31517
+ initialSelectionDone,
31518
+ storageKey2
30890
31519
  ]);
30891
31520
  (0, import_react30.useEffect)(() => {
30892
31521
  if (!tokens.length || !token) return;
@@ -30897,11 +31526,12 @@ function useDefaultToken({
30897
31526
  });
30898
31527
  if (!isChainAvailable) {
30899
31528
  const firstChain = currentToken.chains[0];
30900
- setChain(getChainKey(firstChain.chain_id, firstChain.chain_type));
31529
+ setChainState(getChainKey(firstChain.chain_id, firstChain.chain_type));
30901
31530
  }
30902
31531
  }, [token, tokens, chain]);
30903
31532
  return { token, chain, setToken, setChain, initialSelectionDone };
30904
31533
  }
31534
+ var STORAGE_KEY2 = "unifold_last_deposit_from_token";
30905
31535
  function useDefaultSourceToken({
30906
31536
  supportedTokens,
30907
31537
  defaultSourceChainType,
@@ -30914,7 +31544,8 @@ function useDefaultSourceToken({
30914
31544
  defaultChainType: defaultSourceChainType,
30915
31545
  defaultChainId: defaultSourceChainId,
30916
31546
  defaultTokenAddress: defaultSourceTokenAddress,
30917
- defaultSymbol: defaultSourceSymbol
31547
+ defaultSymbol: defaultSourceSymbol,
31548
+ storageKey: STORAGE_KEY2
30918
31549
  });
30919
31550
  }
30920
31551
  function DepositFooterLinks({ onGlossaryClick, leftElement }) {
@@ -31197,14 +31828,14 @@ function useCopyAddress() {
31197
31828
  return { copied, handleCopy };
31198
31829
  }
31199
31830
  var TooltipProvider2 = Provider;
31200
- var TooltipContext = React322.createContext({
31831
+ var TooltipContext = React332.createContext({
31201
31832
  open: false,
31202
31833
  onOpenChange: () => {
31203
31834
  }
31204
31835
  });
31205
- var TooltipTrigger2 = React322.forwardRef(({ onClick, ...props }, ref) => {
31206
- const { open, onOpenChange } = React322.useContext(TooltipContext);
31207
- const handleClick = React322.useCallback(
31836
+ var TooltipTrigger2 = React332.forwardRef(({ onClick, ...props }, ref) => {
31837
+ const { open, onOpenChange } = React332.useContext(TooltipContext);
31838
+ const handleClick = React332.useCallback(
31208
31839
  (e) => {
31209
31840
  onOpenChange(!open);
31210
31841
  onClick?.(e);
@@ -31214,7 +31845,7 @@ var TooltipTrigger2 = React322.forwardRef(({ onClick, ...props }, ref) => {
31214
31845
  return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Trigger, { ref, onClick: handleClick, ...props });
31215
31846
  });
31216
31847
  TooltipTrigger2.displayName = Trigger.displayName;
31217
- var TooltipContent2 = React322.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
31848
+ var TooltipContent2 = React332.forwardRef(({ className, sideOffset = 4, ...props }, ref) => {
31218
31849
  const { themeClass, colors: colors2 } = useTheme();
31219
31850
  return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(Portal3, { children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
31220
31851
  Content22,
@@ -31245,7 +31876,7 @@ function useHypercoreActivation(params) {
31245
31876
  const recipient = recipientAddress?.trim() ?? "";
31246
31877
  const source = sourceAddress?.trim() ?? "";
31247
31878
  const hasAddresses = !!recipient && !!source;
31248
- const { data, isLoading } = (0, import_react_query16.useQuery)({
31879
+ const { data, isLoading } = (0, import_react_query18.useQuery)({
31249
31880
  queryKey: ["unifold", "hypercoreActivation", source, recipient, publishableKey],
31250
31881
  queryFn: () => checkHypercoreActivation(
31251
31882
  {
@@ -31324,6 +31955,7 @@ function TransferCryptoSingleInput({
31324
31955
  onDepositError,
31325
31956
  wallets: externalWallets,
31326
31957
  onSourceTokenChange,
31958
+ prefilledAmountUsd,
31327
31959
  checkoutQuote,
31328
31960
  isCheckoutQuoteLoading = false,
31329
31961
  persistCheckingIndicator = false,
@@ -31467,6 +32099,22 @@ function TransferCryptoSingleInput({
31467
32099
  const maxSlippage = currentChainFromBackend?.max_slippage_percent ?? 0.25;
31468
32100
  const processingTime = currentChainFromBackend?.estimated_processing_time ?? null;
31469
32101
  const minDepositUsd = currentChainFromBackend?.minimum_deposit_amount_usd ?? 3;
32102
+ const parsedPrefilledUsd = (0, import_react27.useMemo)(() => {
32103
+ const value = parseFloat(prefilledAmountUsd ?? "");
32104
+ return Number.isFinite(value) && value > 0 ? value : null;
32105
+ }, [prefilledAmountUsd]);
32106
+ const effectivePrefilledUsd = (0, import_react27.useMemo)(() => {
32107
+ if (parsedPrefilledUsd === null) return null;
32108
+ return Math.max(parsedPrefilledUsd, minDepositUsd);
32109
+ }, [parsedPrefilledUsd, minDepositUsd]);
32110
+ const prefillDisplay = (0, import_react27.useMemo)(() => {
32111
+ if (effectivePrefilledUsd === null) return null;
32112
+ const usdLabel = `$${effectivePrefilledUsd.toFixed(2)}`;
32113
+ if (selectedToken?.is_stablecoin) {
32114
+ return `${effectivePrefilledUsd.toFixed(2)} ${selectedToken.symbol} (${usdLabel})`;
32115
+ }
32116
+ return `${usdLabel} USD`;
32117
+ }, [effectivePrefilledUsd, selectedToken]);
31470
32118
  return /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(TooltipProvider2, { delayDuration: 0, skipDelayDuration: 0, children: /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
31471
32119
  "div",
31472
32120
  {
@@ -31593,7 +32241,7 @@ function TransferCryptoSingleInput({
31593
32241
  /* @__PURE__ */ (0, import_jsx_runtime71.jsx)("span", { children: "Retrying automatically every 5 seconds..." })
31594
32242
  ] })
31595
32243
  ] }),
31596
- (checkoutQuote || isCheckoutQuoteLoading) && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
32244
+ (checkoutQuote || isCheckoutQuoteLoading || prefillDisplay) && /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
31597
32245
  "div",
31598
32246
  {
31599
32247
  className: "uf-rounded-xl uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
@@ -31637,6 +32285,13 @@ function TransferCryptoSingleInput({
31637
32285
  )
31638
32286
  ]
31639
32287
  }
32288
+ ) : prefillDisplay ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
32289
+ "span",
32290
+ {
32291
+ className: "uf-text-sm uf-font-semibold",
32292
+ style: { color: components.card.titleColor, fontFamily: fonts.semibold },
32293
+ children: prefillDisplay
32294
+ }
31640
32295
  ) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
31641
32296
  "div",
31642
32297
  {
@@ -31966,7 +32621,7 @@ function TransferCryptoSingleInput({
31966
32621
  }
31967
32622
  var Select2 = Root23;
31968
32623
  var SelectValue2 = Value;
31969
- var SelectTrigger2 = React332.forwardRef(({ className, style, children, ...props }, ref) => {
32624
+ var SelectTrigger2 = React342.forwardRef(({ className, style, children, ...props }, ref) => {
31970
32625
  const { components } = useTheme();
31971
32626
  return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
31972
32627
  Trigger2,
@@ -31990,7 +32645,7 @@ var SelectTrigger2 = React332.forwardRef(({ className, style, children, ...props
31990
32645
  );
31991
32646
  });
31992
32647
  SelectTrigger2.displayName = Trigger2.displayName;
31993
- var SelectScrollUpButton2 = React332.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32648
+ var SelectScrollUpButton2 = React342.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
31994
32649
  ScrollUpButton,
31995
32650
  {
31996
32651
  ref,
@@ -32000,7 +32655,7 @@ var SelectScrollUpButton2 = React332.forwardRef(({ className, ...props }, ref) =
32000
32655
  }
32001
32656
  ));
32002
32657
  SelectScrollUpButton2.displayName = ScrollUpButton.displayName;
32003
- var SelectScrollDownButton2 = React332.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32658
+ var SelectScrollDownButton2 = React342.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32004
32659
  ScrollDownButton,
32005
32660
  {
32006
32661
  ref,
@@ -32010,7 +32665,7 @@ var SelectScrollDownButton2 = React332.forwardRef(({ className, ...props }, ref)
32010
32665
  }
32011
32666
  ));
32012
32667
  SelectScrollDownButton2.displayName = ScrollDownButton.displayName;
32013
- var SelectContent2 = React332.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
32668
+ var SelectContent2 = React342.forwardRef(({ className, style, children, position = "popper", ...props }, ref) => {
32014
32669
  const { themeClass, colors: colors2, components } = useTheme();
32015
32670
  return /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(Portal4, { children: /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
32016
32671
  Content23,
@@ -32048,7 +32703,7 @@ var SelectContent2 = React332.forwardRef(({ className, style, children, position
32048
32703
  ) });
32049
32704
  });
32050
32705
  SelectContent2.displayName = Content23.displayName;
32051
- var SelectLabel2 = React332.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32706
+ var SelectLabel2 = React342.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32052
32707
  Label,
32053
32708
  {
32054
32709
  ref,
@@ -32057,7 +32712,7 @@ var SelectLabel2 = React332.forwardRef(({ className, ...props }, ref) => /* @__P
32057
32712
  }
32058
32713
  ));
32059
32714
  SelectLabel2.displayName = Label.displayName;
32060
- var SelectItem2 = React332.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
32715
+ var SelectItem2 = React342.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
32061
32716
  Item,
32062
32717
  {
32063
32718
  ref,
@@ -32073,7 +32728,7 @@ var SelectItem2 = React332.forwardRef(({ className, children, ...props }, ref) =
32073
32728
  }
32074
32729
  ));
32075
32730
  SelectItem2.displayName = Item.displayName;
32076
- var SelectSeparator2 = React332.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32731
+ var SelectSeparator2 = React342.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
32077
32732
  Separator,
32078
32733
  {
32079
32734
  ref,
@@ -32101,6 +32756,7 @@ function TransferCryptoDoubleInput({
32101
32756
  defaultSourceChainId,
32102
32757
  defaultSourceTokenAddress,
32103
32758
  defaultSourceSymbol,
32759
+ prefilledAmountUsd,
32104
32760
  depositConfirmationMode = "auto_ui",
32105
32761
  onExecutionsChange,
32106
32762
  onDepositSuccess,
@@ -32225,6 +32881,22 @@ function TransferCryptoDoubleInput({
32225
32881
  const maxSlippage = currentChainFromBackend?.max_slippage_percent ?? 0.25;
32226
32882
  const processingTime = currentChainFromBackend?.estimated_processing_time ?? null;
32227
32883
  const minDepositUsd = currentChainFromBackend?.minimum_deposit_amount_usd ?? 3;
32884
+ const parsedPrefilledUsd = (0, import_react32.useMemo)(() => {
32885
+ const value = parseFloat(prefilledAmountUsd ?? "");
32886
+ return Number.isFinite(value) && value > 0 ? value : null;
32887
+ }, [prefilledAmountUsd]);
32888
+ const effectivePrefilledUsd = (0, import_react32.useMemo)(() => {
32889
+ if (parsedPrefilledUsd === null) return null;
32890
+ return Math.max(parsedPrefilledUsd, minDepositUsd);
32891
+ }, [parsedPrefilledUsd, minDepositUsd]);
32892
+ const prefillDisplay = (0, import_react32.useMemo)(() => {
32893
+ if (effectivePrefilledUsd === null) return null;
32894
+ const usdLabel = `$${effectivePrefilledUsd.toFixed(2)}`;
32895
+ if (selectedToken?.is_stablecoin) {
32896
+ return `${effectivePrefilledUsd.toFixed(2)} ${selectedToken.symbol} (${usdLabel})`;
32897
+ }
32898
+ return `${usdLabel} USD`;
32899
+ }, [effectivePrefilledUsd, selectedToken]);
32228
32900
  const renderTokenItem = (tokenData) => {
32229
32901
  return /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
32230
32902
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
@@ -32405,6 +33077,35 @@ function TransferCryptoDoubleInput({
32405
33077
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("span", { children: "Retrying automatically every 5 seconds..." })
32406
33078
  ] })
32407
33079
  ] }),
33080
+ prefillDisplay && /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
33081
+ "div",
33082
+ {
33083
+ className: "uf-rounded-xl uf-px-3 uf-py-2 uf-flex uf-items-center uf-justify-between",
33084
+ style: {
33085
+ backgroundColor: components.card.backgroundColor,
33086
+ border: `${components.card.borderWidth}px solid ${components.card.borderColor}`,
33087
+ borderRadius: components.card.borderRadius
33088
+ },
33089
+ children: [
33090
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
33091
+ "span",
33092
+ {
33093
+ className: "uf-text-xs",
33094
+ style: { color: components.card.subtitleColor, fontFamily: fonts.regular },
33095
+ children: "You send"
33096
+ }
33097
+ ),
33098
+ /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
33099
+ "span",
33100
+ {
33101
+ className: "uf-text-sm uf-font-semibold",
33102
+ style: { color: components.card.titleColor, fontFamily: fonts.semibold },
33103
+ children: prefillDisplay
33104
+ }
33105
+ )
33106
+ ]
33107
+ }
33108
+ ),
32408
33109
  /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-pt-2", children: [
32409
33110
  /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
32410
33111
  "div",
@@ -32743,7 +33444,7 @@ function useDepositQuote(params) {
32743
33444
  ...adjustForSlippage ? { adjust_for_slippage: true } : {},
32744
33445
  ...stablecoinParity ? { stablecoin_parity: true } : {}
32745
33446
  };
32746
- return (0, import_react_query17.useQuery)({
33447
+ return (0, import_react_query19.useQuery)({
32747
33448
  queryKey: [
32748
33449
  "unifold",
32749
33450
  "depositQuote",
@@ -32773,7 +33474,7 @@ function useExternalWallets({
32773
33474
  publishableKey,
32774
33475
  enabled = true
32775
33476
  }) {
32776
- const { data: wallets = [], isLoading } = (0, import_react_query18.useQuery)({
33477
+ const { data: wallets = [], isLoading } = (0, import_react_query20.useQuery)({
32777
33478
  queryKey: ["unifold", "external-wallets", publishableKey],
32778
33479
  queryFn: () => getExternalWallets(publishableKey).then((res) => res.data),
32779
33480
  enabled: enabled && !!publishableKey,
@@ -33856,33 +34557,11 @@ function balancesRepresentSameToken(a, b) {
33856
34557
  if (!tokenA || !tokenB) return false;
33857
34558
  return tokenA.chain_type === tokenB.chain_type && tokenA.chain_id === tokenB.chain_id && normalizeTokenAddress(tokenA.token_address) === normalizeTokenAddress(tokenB.token_address);
33858
34559
  }
33859
- function getSolanaProviders() {
33860
- if (typeof window === "undefined") return {};
33861
- const win = window;
33862
- return {
33863
- phantomSolana: win.phantom?.solana,
33864
- solflare: win.solflare,
33865
- backpack: win.backpack,
33866
- glow: win.glow,
33867
- coinbaseSolana: win.coinbaseSolana || win.coinbaseWalletExtension?.solana
33868
- };
33869
- }
33870
- function getLegacyEvmProviders() {
33871
- if (typeof window === "undefined") return {};
33872
- const win = window;
33873
- return {
33874
- ethereum: win.ethereum,
33875
- phantomEthereum: win.phantom?.ethereum,
33876
- coinbaseEthereum: win.coinbaseWalletExtension,
33877
- trustEthereum: win.trustwallet?.ethereum,
33878
- okxEthereum: win.okxwallet
33879
- };
33880
- }
33881
34560
  function detectAvailableWallets(definitions, recentWalletId, filterChainType) {
33882
- const solProviders = getSolanaProviders();
33883
- const legacyEvm = getLegacyEvmProviders();
33884
- const eip6963List = getEip6963Providers();
33885
34561
  const win = typeof window !== "undefined" ? window : null;
34562
+ const solProviders = getInjectedSolanaProviders(win);
34563
+ const legacyEvm = getLegacyEvmProviders(win);
34564
+ const eip6963List = getEip6963Providers();
33886
34565
  const hasEip6963 = (walletId) => eip6963List.some((d) => {
33887
34566
  const rdns = d.info?.rdns || "";
33888
34567
  switch (walletId) {
@@ -33992,7 +34671,7 @@ function WalletConnect({
33992
34671
  amountQuickSelect = "percentage",
33993
34672
  onWalletDisconnect,
33994
34673
  onWalletConnected,
33995
- prefillAmountUsd,
34674
+ prefilledAmountUsd,
33996
34675
  checkoutAmountUsd,
33997
34676
  checkoutReceivedUsd,
33998
34677
  onNewDeposit,
@@ -34014,28 +34693,28 @@ function WalletConnect({
34014
34693
  onExecutionsChange
34015
34694
  }) {
34016
34695
  const { colors: colors2, fonts, components, mode } = useTheme();
34017
- const walletProvidedAtMount = React342.useRef(!!initialWalletInfo && !!initialDepositWallet);
34018
- const [activeWalletInfo, setActiveWalletInfo] = React342.useState(
34696
+ const walletProvidedAtMount = React352.useRef(!!initialWalletInfo && !!initialDepositWallet);
34697
+ const [activeWalletInfo, setActiveWalletInfo] = React352.useState(
34019
34698
  initialWalletInfo ?? null
34020
34699
  );
34021
- const [activeDepositWallet, setActiveDepositWallet] = React342.useState(
34700
+ const [activeDepositWallet, setActiveDepositWallet] = React352.useState(
34022
34701
  initialDepositWallet ?? null
34023
34702
  );
34024
34703
  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);
34704
+ const [view, setView] = React352.useState(initialView);
34705
+ const [isTransitioning, setIsTransitioning] = React352.useState(false);
34706
+ const viewRef = React352.useRef(initialView);
34028
34707
  const standalone = !canGoBack && !walletProvidedAtMount.current;
34029
34708
  const { wallet: detectedWallet, isLoading: detectingWallet } = useDetectedBrowserWallet({
34030
34709
  enabled: standalone
34031
34710
  });
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(() => {
34711
+ const [autoResolved, setAutoResolved] = React352.useState(false);
34712
+ const [selectedWalletDef, setSelectedWalletDef] = React352.useState(null);
34713
+ const [connectingNetwork, setConnectingNetwork] = React352.useState(null);
34714
+ const [walletError, setWalletError] = React352.useState(null);
34715
+ const [isWalletConnecting, setIsWalletConnecting] = React352.useState(false);
34716
+ const [eip6963ProviderCount, setEip6963ProviderCount] = React352.useState(0);
34717
+ React352.useEffect(() => {
34039
34718
  const store = getEip6963Store();
34040
34719
  if (!store) return;
34041
34720
  setEip6963ProviderCount(store.getProviders().length);
@@ -34044,7 +34723,7 @@ function WalletConnect({
34044
34723
  });
34045
34724
  }, []);
34046
34725
  const { wallets: backendWallets } = useExternalWallets({ publishableKey });
34047
- const walletDefinitions = React342.useMemo(
34726
+ const walletDefinitions = React352.useMemo(
34048
34727
  () => backendWallets.length > 0 ? backendWallets.map((w) => ({
34049
34728
  id: w.id,
34050
34729
  name: w.name,
@@ -34055,32 +34734,32 @@ function WalletConnect({
34055
34734
  })) : FALLBACK_WALLET_DEFINITIONS,
34056
34735
  [backendWallets]
34057
34736
  );
34058
- const [recentWalletId, setRecentWalletIdState] = React342.useState(getLastOpenedWallet);
34059
- React342.useEffect(() => {
34737
+ const [recentWalletId, setRecentWalletIdState] = React352.useState(getLastOpenedWallet);
34738
+ React352.useEffect(() => {
34060
34739
  if (view === "select_wallet") {
34061
34740
  setRecentWalletIdState(getLastOpenedWallet());
34062
34741
  }
34063
34742
  }, [view]);
34064
- const availableWallets = React342.useMemo(
34743
+ const availableWallets = React352.useMemo(
34065
34744
  () => detectAvailableWallets(walletDefinitions, recentWalletId),
34066
34745
  [walletDefinitions, eip6963ProviderCount, recentWalletId]
34067
34746
  );
34068
- const [isMobile, setIsMobile] = React342.useState(false);
34069
- React342.useEffect(() => {
34747
+ const [isMobile, setIsMobile] = React352.useState(false);
34748
+ React352.useEffect(() => {
34070
34749
  setIsMobile(isMobileDevice());
34071
34750
  }, []);
34072
- const mobileDepositAddresses = React342.useMemo(
34751
+ const mobileDepositAddresses = React352.useMemo(
34073
34752
  () => (depositWallets ?? []).map((w) => ({ chain_type: w.chain_type, address: w.address })),
34074
34753
  [depositWallets]
34075
34754
  );
34076
- const mobileDepositWalletIds = React342.useMemo(
34755
+ const mobileDepositWalletIds = React352.useMemo(
34077
34756
  () => (depositWallets ?? []).filter((w) => w.chain_type === "ethereum" || w.chain_type === "solana").map((w) => w.id),
34078
34757
  [depositWallets]
34079
34758
  );
34080
- const [mobileRedirect, setMobileRedirect] = React342.useState(null);
34081
- const [pendingMobileWallet, setPendingMobileWallet] = React342.useState(null);
34082
- const [awaitingMobileDeposit, setAwaitingMobileDeposit] = React342.useState(false);
34083
- React342.useEffect(() => {
34759
+ const [mobileRedirect, setMobileRedirect] = React352.useState(null);
34760
+ const [pendingMobileWallet, setPendingMobileWallet] = React352.useState(null);
34761
+ const [awaitingMobileDeposit, setAwaitingMobileDeposit] = React352.useState(false);
34762
+ React352.useEffect(() => {
34084
34763
  if (!standalone || autoResolved || detectingWallet) return;
34085
34764
  if (!detectedWallet) {
34086
34765
  setAutoResolved(true);
@@ -34106,32 +34785,36 @@ function WalletConnect({
34106
34785
  depositWallets,
34107
34786
  depositWalletsLoading
34108
34787
  ]);
34109
- React342.useEffect(() => {
34788
+ React352.useEffect(() => {
34110
34789
  if (!standalone || autoResolved) return;
34111
34790
  const t13 = setTimeout(() => setAutoResolved(true), 5e3);
34112
34791
  return () => clearTimeout(t13);
34113
34792
  }, [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);
34793
+ const [balances, setBalances] = React352.useState([]);
34794
+ const [isLoading, setIsLoading] = React352.useState(false);
34795
+ const [selectedBalance, setSelectedBalance] = React352.useState(null);
34796
+ const [totalBalanceUsd, setTotalBalanceUsd] = React352.useState(null);
34797
+ const [error, setError] = React352.useState(null);
34798
+ const [isDisconnectingWallet, setIsDisconnectingWallet] = React352.useState(false);
34799
+ const [amountUsd, setAmountUsd] = React352.useState(prefilledAmountUsd ?? "");
34800
+ const [isConfirming, setIsConfirming] = React352.useState(false);
34801
+ const [hasSignedTransaction, setHasSignedTransaction] = React352.useState(false);
34802
+ const [tokenChainDetails, setTokenChainDetails] = React352.useState(null);
34803
+ const [loadingTokenDetails, setLoadingTokenDetails] = React352.useState(false);
34804
+ const [showTransactionDetails, setShowTransactionDetails] = React352.useState(false);
34805
+ const [receivedUsdAtSubmission, setReceivedUsdAtSubmission] = React352.useState(null);
34127
34806
  const walletInfo = activeWalletInfo;
34128
34807
  const depositWallet = activeDepositWallet;
34129
34808
  const hasWallet = !!activeWalletInfo && !!activeDepositWallet;
34809
+ React352.useEffect(() => {
34810
+ const cleanedPrefilled = prefilledAmountUsd?.replace(/[^0-9.]/g, "") ?? "";
34811
+ setAmountUsd(cleanedPrefilled);
34812
+ }, [prefilledAmountUsd]);
34130
34813
  const chainType = activeDepositWallet?.chain_type ?? "ethereum";
34131
34814
  const recipientAddress = activeDepositWallet?.address ?? "";
34132
34815
  const isCheckoutMode = !!checkoutAmountUsd;
34133
34816
  const supportedChainType = chainType === "algorand" || chainType === "xrpl" || chainType === "cardano" || chainType === "n1" ? "ethereum" : chainType;
34134
- const transitionTo = React342.useCallback((nextView) => {
34817
+ const transitionTo = React352.useCallback((nextView) => {
34135
34818
  if (nextView === viewRef.current) return;
34136
34819
  setIsTransitioning(true);
34137
34820
  setTimeout(() => {
@@ -34147,10 +34830,13 @@ function WalletConnect({
34147
34830
  };
34148
34831
  const openMobileWalletBrowse = async (wallet, depositAddresses) => {
34149
34832
  try {
34833
+ const cleanedAmountUsd = amountUsd?.replace(/[^0-9.]/g, "") ?? "";
34834
+ const forwardedAmountUsd = parseFloat(cleanedAmountUsd) > 0 ? cleanedAmountUsd : void 0;
34150
34835
  const res = await getWalletMobileDeepLink(
34151
34836
  wallet.id,
34152
34837
  depositAddresses,
34153
- publishableKey
34838
+ publishableKey,
34839
+ forwardedAmountUsd
34154
34840
  );
34155
34841
  if (res.deeplink) {
34156
34842
  setMobileRedirect({ walletId: wallet.id, walletName: wallet.name, deeplink: res.deeplink });
@@ -34196,7 +34882,7 @@ function WalletConnect({
34196
34882
  if (!selectedWalletDef) return;
34197
34883
  handleConnectWallet(selectedWalletDef, network);
34198
34884
  };
34199
- React342.useEffect(() => {
34885
+ React352.useEffect(() => {
34200
34886
  if (!pendingMobileWallet) return;
34201
34887
  if (mobileDepositAddresses.length > 0) {
34202
34888
  const wallet = pendingMobileWallet;
@@ -34239,7 +34925,7 @@ function WalletConnect({
34239
34925
  const eip6963Match = findProviderByWalletId(wallet.id);
34240
34926
  let provider = eip6963Match?.provider;
34241
34927
  if (!provider) {
34242
- const legacyEvm = getLegacyEvmProviders();
34928
+ const legacyEvm = getLegacyEvmProviders(win);
34243
34929
  switch (wallet.id) {
34244
34930
  case "metamask":
34245
34931
  if (legacyEvm.ethereum?.isMetaMask && !legacyEvm.ethereum?.isPhantom)
@@ -34271,16 +34957,7 @@ function WalletConnect({
34271
34957
  const accounts = await provider.request({ method: "eth_requestAccounts" });
34272
34958
  if (!accounts?.length) throw new Error("No accounts returned from wallet");
34273
34959
  setUserDisconnectedWallet(false);
34274
- const walletIdToType = {
34275
- phantom: "phantom-ethereum",
34276
- coinbase: "coinbase",
34277
- trust: "trust",
34278
- rainbow: "rainbow",
34279
- rabby: "rabby",
34280
- okx: "okx",
34281
- metamask: "metamask"
34282
- };
34283
- const walletType = walletIdToType[wallet.id] || "metamask";
34960
+ const walletType = walletIdToWalletType(wallet.id);
34284
34961
  setStoredWalletState(walletType);
34285
34962
  connectedInfo = {
34286
34963
  type: walletType,
@@ -34289,7 +34966,7 @@ function WalletConnect({
34289
34966
  icon: wallet.id
34290
34967
  };
34291
34968
  } else {
34292
- const solProviders = getSolanaProviders();
34969
+ const solProviders = getInjectedSolanaProviders(win);
34293
34970
  let provider;
34294
34971
  switch (wallet.id) {
34295
34972
  case "phantom":
@@ -34308,11 +34985,11 @@ function WalletConnect({
34308
34985
  provider = solProviders.coinbaseSolana || win?.coinbaseWalletExtension?.solana;
34309
34986
  break;
34310
34987
  case "trust":
34311
- provider = win?.trustwallet?.solana;
34988
+ provider = solProviders.trustSolana;
34312
34989
  break;
34313
34990
  }
34314
34991
  if (!provider) throw new Error(`${wallet.name} Solana wallet not found.`);
34315
- const response = await provider.connect();
34992
+ const response = await connectSolanaProviderWithRecovery(provider, wallet.id, wallet.name);
34316
34993
  setUserDisconnectedWallet(false);
34317
34994
  const walletType = wallet.id === "solflare" ? "solflare" : wallet.id === "backpack" ? "backpack" : wallet.id === "glow" ? "glow" : "phantom-solana";
34318
34995
  setStoredWalletState(walletType);
@@ -34360,7 +35037,7 @@ function WalletConnect({
34360
35037
  publishableKey,
34361
35038
  enabled: !!activeWalletInfo && !!recipientAddress
34362
35039
  });
34363
- const effectiveDestinationAmount = React342.useMemo(() => {
35040
+ const effectiveDestinationAmount = React352.useMemo(() => {
34364
35041
  if (!checkoutRemainingBaseUnits || checkoutRemainingBaseUnits === "0") return "0";
34365
35042
  if (!checkoutAmountUsd) return checkoutRemainingBaseUnits;
34366
35043
  const remaining = BigInt(checkoutRemainingBaseUnits);
@@ -34388,7 +35065,7 @@ function WalletConnect({
34388
35065
  stablecoinParity,
34389
35066
  enabled: isCheckoutMode && !!selectedToken && !!checkoutDestination && effectiveDestinationAmount !== "0"
34390
35067
  });
34391
- const activeCheckoutQuote = React342.useMemo(() => {
35068
+ const activeCheckoutQuote = React352.useMemo(() => {
34392
35069
  if (!isCheckoutMode) return null;
34393
35070
  if (walletCheckoutQuote)
34394
35071
  return {
@@ -34418,10 +35095,10 @@ function WalletConnect({
34418
35095
  onDepositSuccess,
34419
35096
  onDepositError
34420
35097
  });
34421
- React342.useEffect(() => {
35098
+ React352.useEffect(() => {
34422
35099
  onExecutionsChange?.(depositExecutions);
34423
35100
  }, [depositExecutions, onExecutionsChange]);
34424
- const latestDepositExecution = React342.useMemo(() => {
35101
+ const latestDepositExecution = React352.useMemo(() => {
34425
35102
  if (depositExecutions.length === 0) return null;
34426
35103
  return [...depositExecutions].sort((a, b) => {
34427
35104
  const ta = a.created_at ? new Date(a.created_at).getTime() : 0;
@@ -34429,21 +35106,21 @@ function WalletConnect({
34429
35106
  return tb - ta;
34430
35107
  })[0];
34431
35108
  }, [depositExecutions]);
34432
- React342.useEffect(() => {
35109
+ React352.useEffect(() => {
34433
35110
  if (awaitingMobileDeposit && latestDepositExecution && (viewRef.current === "mobile_redirect" || viewRef.current === "connecting")) {
34434
35111
  transitionTo("mobile_deposit_status");
34435
35112
  }
34436
35113
  }, [awaitingMobileDeposit, latestDepositExecution, transitionTo]);
34437
- React342.useEffect(() => {
34438
- if (!prefillAmountUsd || !tokenChainDetails || view !== "enter_amount") return;
35114
+ React352.useEffect(() => {
35115
+ if (!isCheckoutMode || !tokenChainDetails || view !== "enter_amount") return;
34439
35116
  const minDeposit = tokenChainDetails.minimum_deposit_amount_usd || 0;
34440
35117
  const currentAmount = parseFloat(amountUsd) || 0;
34441
35118
  if (currentAmount > 0 && currentAmount < minDeposit) setAmountUsd(minDeposit.toFixed(2));
34442
- }, [tokenChainDetails, view, prefillAmountUsd]);
34443
- React342.useEffect(() => {
35119
+ }, [isCheckoutMode, tokenChainDetails, view, amountUsd]);
35120
+ React352.useEffect(() => {
34444
35121
  if (view === "review") setShowTransactionDetails(false);
34445
35122
  }, [view]);
34446
- React342.useEffect(() => {
35123
+ React352.useEffect(() => {
34447
35124
  if (view !== "enter_amount" && view !== "review" || !selectedBalance || !activeDepositWallet)
34448
35125
  return;
34449
35126
  let cancelled = false;
@@ -34480,7 +35157,7 @@ function WalletConnect({
34480
35157
  cancelled = true;
34481
35158
  };
34482
35159
  }, [view, selectedBalance, publishableKey, activeDepositWallet]);
34483
- React342.useEffect(() => {
35160
+ React352.useEffect(() => {
34484
35161
  if (!activeWalletInfo || !activeDepositWallet) return;
34485
35162
  let cancelled = false;
34486
35163
  setIsLoading(true);
@@ -34545,21 +35222,21 @@ function WalletConnect({
34545
35222
  defaultSourceTokenAddress,
34546
35223
  defaultSourceSymbol
34547
35224
  ]);
34548
- const usdToTokenRate = React342.useMemo(() => {
35225
+ const usdToTokenRate = React352.useMemo(() => {
34549
35226
  if (!selectedBalance || !selectedBalance.amount_usd || !selectedToken) return 0;
34550
35227
  const balanceAmount = Number(selectedBalance.amount) / 10 ** selectedToken.decimals;
34551
35228
  const balanceUsd = parseFloat(selectedBalance.amount_usd);
34552
35229
  if (balanceAmount === 0 || balanceUsd === 0) return 0;
34553
35230
  return balanceAmount / balanceUsd;
34554
35231
  }, [selectedBalance, selectedToken]);
34555
- const tokenAmount = React342.useMemo(() => {
35232
+ const tokenAmount = React352.useMemo(() => {
34556
35233
  if (isCheckoutMode && activeCheckoutQuote && selectedToken)
34557
35234
  return Number(activeCheckoutQuote.sourceAmount) / 10 ** activeCheckoutQuote.sourceTokenDecimals;
34558
35235
  const usdNum = parseFloat(amountUsd) || 0;
34559
35236
  if (usdNum === 0 || usdToTokenRate === 0) return 0;
34560
35237
  return usdNum * usdToTokenRate;
34561
35238
  }, [amountUsd, usdToTokenRate, isCheckoutMode, activeCheckoutQuote, selectedToken]);
34562
- React342.useEffect(() => {
35239
+ React352.useEffect(() => {
34563
35240
  if (isCheckoutMode && activeCheckoutQuote?.sourceAmountUsd && view === "enter_amount")
34564
35241
  setAmountUsd(activeCheckoutQuote.sourceAmountUsd);
34565
35242
  }, [isCheckoutMode, activeCheckoutQuote, view]);
@@ -34568,7 +35245,7 @@ function WalletConnect({
34568
35245
  const inputUsdNum = parseFloat(amountUsd) || 0;
34569
35246
  const minDepositUsd = tokenChainDetails?.minimum_deposit_amount_usd || 0;
34570
35247
  const isValidAmount = isCheckoutMode && activeCheckoutQuote ? tokenAmount > 0 && tokenAmount <= maxTokenAmount : inputUsdNum > 0 && inputUsdNum <= maxUsdAmount && inputUsdNum >= minDepositUsd;
34571
- const formattedTokenAmount = React342.useMemo(() => {
35248
+ const formattedTokenAmount = React352.useMemo(() => {
34572
35249
  if (tokenAmount === 0 || !selectedToken) return null;
34573
35250
  return `${tokenAmount.toFixed(6)} ${selectedToken.symbol}`.replace(/\.?0+$/, "");
34574
35251
  }, [tokenAmount, selectedToken]);
@@ -34601,7 +35278,7 @@ function WalletConnect({
34601
35278
  break;
34602
35279
  case "enter_amount":
34603
35280
  transitionTo("select_token");
34604
- setAmountUsd(prefillAmountUsd ?? "");
35281
+ setAmountUsd(prefilledAmountUsd ?? "");
34605
35282
  setTokenChainDetails(null);
34606
35283
  break;
34607
35284
  case "review":
@@ -34633,7 +35310,7 @@ function WalletConnect({
34633
35310
  setSelectedBalance(null);
34634
35311
  setBalances([]);
34635
35312
  setTotalBalanceUsd(null);
34636
- setAmountUsd(prefillAmountUsd ?? "");
35313
+ setAmountUsd(prefilledAmountUsd ?? "");
34637
35314
  setError(null);
34638
35315
  };
34639
35316
  if (standalone) {
@@ -34663,16 +35340,7 @@ function WalletConnect({
34663
35340
  return (integerPart + decimalPart.padEnd(decimals, "0").slice(0, decimals)).replace(/^0+/, "") || "0";
34664
35341
  };
34665
35342
  const resolveEvmProvider = () => {
34666
- const walletIdMap = {
34667
- "phantom-ethereum": "phantom",
34668
- coinbase: "coinbase",
34669
- trust: "trust",
34670
- okx: "okx",
34671
- rainbow: "rainbow",
34672
- rabby: "rabby",
34673
- metamask: "metamask"
34674
- };
34675
- const lookupId = walletIdMap[walletInfo.type] || walletInfo.type;
35343
+ const lookupId = walletTypeToWalletId(walletInfo.type);
34676
35344
  const eip6963Match = findProviderByWalletId(lookupId);
34677
35345
  let provider = eip6963Match?.provider;
34678
35346
  if (!provider) {
@@ -35357,6 +36025,15 @@ function SkeletonButton({ variant = "default" }) {
35357
36025
  ] });
35358
36026
  }
35359
36027
  var t8 = i18n2.depositModal;
36028
+ function normalizePrefilledUsdAmount(value) {
36029
+ if (!value) return void 0;
36030
+ const cleaned = value.replace(/[^0-9.]/g, "");
36031
+ if (!cleaned) return void 0;
36032
+ const normalizedNumeric = cleaned.replace(/(\..*)\./g, "$1");
36033
+ const parsed = parseFloat(normalizedNumeric);
36034
+ if (!Number.isFinite(parsed) || parsed <= 0) return void 0;
36035
+ return parseFloat(parsed.toFixed(2)).toString();
36036
+ }
35360
36037
  function depositTabForScreen(screen) {
35361
36038
  return screen === "card" || screen === "cashapp" || screen === "bank_transfer" || screen === "stripe_link" || screen === "apple_pay" ? "cash" : "crypto";
35362
36039
  }
@@ -35376,6 +36053,7 @@ function DepositModal({
35376
36053
  defaultSourceChainId,
35377
36054
  defaultSourceTokenAddress,
35378
36055
  defaultSourceSymbol,
36056
+ prefilledAmountUsd,
35379
36057
  hideDepositTracker,
35380
36058
  showBalanceHeader = false,
35381
36059
  transferInputVariant = "double_input",
@@ -35391,6 +36069,7 @@ function DepositModal({
35391
36069
  applePayTitle = "Pay with Apple Pay",
35392
36070
  applePaySubTitle = "Instant",
35393
36071
  enableBankTransfer,
36072
+ enableIncidentBanner = false,
35394
36073
  // No default: left undefined so the backend `stripe_link.enabled` can govern
35395
36074
  // (via the `??` chain in showStripeLink) once a dashboard toggle exists.
35396
36075
  enableStripeLink,
@@ -35411,6 +36090,10 @@ function DepositModal({
35411
36090
  depositTrackerSubTitle = t8.depositTracker.subtitle
35412
36091
  }) {
35413
36092
  const { colors: colors2, fonts, components } = useTheme();
36093
+ const normalizedPrefilledAmountUsd = (0, import_react8.useMemo)(
36094
+ () => normalizePrefilledUsdAmount(prefilledAmountUsd),
36095
+ [prefilledAmountUsd]
36096
+ );
35414
36097
  const onDepositSuccessFor = (0, import_react8.useCallback)(
35415
36098
  (method) => onDepositSuccess || onEvent ? (data) => {
35416
36099
  const payload = { ...data, method };
@@ -35432,7 +36115,7 @@ function DepositModal({
35432
36115
  const s = initialScreen ?? "main";
35433
36116
  if (s === "tracker" && hideDepositTracker === true) return "main";
35434
36117
  if (s === "cashapp" && enableCashApp === false) return "main";
35435
- if (s === "stripe_link" && !enableStripeLink) return "main";
36118
+ if (s === "stripe_link" && enableStripeLink === false) return "main";
35436
36119
  if (s === "apple_pay" && enableApplePay === false) return "main";
35437
36120
  if (s === "card" && enableFiatOnramp === false) return "main";
35438
36121
  if (s === "pay_with_exchange") return enablePayWithExchange === false ? "main" : "exchange";
@@ -35491,6 +36174,16 @@ function DepositModal({
35491
36174
  const showApplePay = enableApplePay ?? projectConfig?.apple_pay?.enabled ?? true;
35492
36175
  const showBankTransfer = enableBankTransfer ?? projectConfig?.bank_transfer?.enabled ?? true;
35493
36176
  const showDepositTracker = hideDepositTracker ? false : projectConfig?.deposit_tracker?.enabled ?? true;
36177
+ const { incident: publicIncident } = usePublicIncident({
36178
+ publishableKey,
36179
+ enabled: open && enableIncidentBanner
36180
+ });
36181
+ const activeIncident = enableIncidentBanner && publicIncident?.enabled && (publicIncident.messages?.length ?? 0) > 0 ? {
36182
+ enabled: true,
36183
+ messages: publicIncident.messages,
36184
+ severity: publicIncident.severity,
36185
+ statusPageUrl: publicIncident.status_page_url
36186
+ } : void 0;
35494
36187
  const [integrationExchanges, setIntegrationExchanges] = (0, import_react8.useState)([]);
35495
36188
  (0, import_react8.useEffect)(() => {
35496
36189
  if (!showConnectExchange || !open) return;
@@ -35557,7 +36250,11 @@ function DepositModal({
35557
36250
  setConnectedExchange((prev) => prev ? { ...prev, iconUrl } : prev);
35558
36251
  }
35559
36252
  }, [integrationExchanges, connectedExchange]);
35560
- const { data: depositAddressResponse, isLoading: walletsLoading } = useDepositAddress({
36253
+ const {
36254
+ data: depositAddressResponse,
36255
+ isLoading: walletsLoading,
36256
+ error: walletsError
36257
+ } = useDepositAddress({
35561
36258
  userId,
35562
36259
  publishableKey,
35563
36260
  recipientAddress,
@@ -35690,6 +36387,7 @@ function DepositModal({
35690
36387
  const {
35691
36388
  isValid: isAddressValid,
35692
36389
  failureCode: addressFailureCode,
36390
+ message: addressFailureMessage,
35693
36391
  metadata: addressFailureMetadata,
35694
36392
  isLoading: isAddressValidationLoading
35695
36393
  } = useAddressValidation({
@@ -35703,17 +36401,31 @@ function DepositModal({
35703
36401
  refetchOnMount: "always"
35704
36402
  });
35705
36403
  const addressValidationMessages = i18n2.transferCrypto.addressValidation;
35706
- const getAddressValidationErrorMessage = (code, metadata) => {
36404
+ const getAddressValidationErrorMessage = (message, code, metadata) => {
36405
+ if (message && message.trim().length > 0) return message;
35707
36406
  if (!code) return addressValidationMessages.defaultError;
35708
36407
  const errors = addressValidationMessages.errors;
35709
36408
  const template = errors[code] ?? addressValidationMessages.defaultError;
35710
36409
  return interpolate(template, metadata);
35711
36410
  };
36411
+ const walletsRecipientError = isDepositAddressValidationError(walletsError) ? walletsError.message : null;
36412
+ const isRecipientAddressInvalid = isAddressValid === false || walletsRecipientError !== null;
36413
+ const recipientInvalidMessage = getAddressValidationErrorMessage(
36414
+ addressFailureMessage ?? walletsRecipientError,
36415
+ addressFailureCode,
36416
+ addressFailureMetadata
36417
+ );
35712
36418
  const openingScreen = effectiveInitialScreen;
35713
36419
  const sessionOpenedFromMenu = openingScreen === "main";
35714
36420
  const standaloneNeedsDepositPrereq = openingScreen !== "main" && (view === "transfer" || view === "card");
35715
36421
  let depositPrerequisiteBody;
35716
- if (isCountryLoading || isAddressValidationLoading || tokensLoading || walletsLoading || !projectConfig || // Bank-transfer row visibility depends on the country-gated providers
36422
+ if (isRecipientAddressInvalid) {
36423
+ depositPrerequisiteBody = /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
36424
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "uf-w-16 uf-h-16 uf-rounded-full uf-bg-muted uf-flex uf-items-center uf-justify-center uf-mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(TriangleAlert, { className: "uf-w-8 uf-h-8 uf-text-muted-foreground" }) }),
36425
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("h3", { className: "uf-text-lg uf-font-semibold uf-text-foreground uf-mb-2", children: addressValidationMessages.unableToReceiveFunds }),
36426
+ /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { className: "uf-text-sm uf-text-muted-foreground uf-max-w-[280px]", children: recipientInvalidMessage })
36427
+ ] });
36428
+ } else if (isCountryLoading || isAddressValidationLoading || tokensLoading || walletsLoading || !projectConfig || // Bank-transfer row visibility depends on the country-gated providers
35717
36429
  // fetch — block the menu on it so the row never flashes in or out.
35718
36430
  showBankTransfer && bankTransferProvidersLoading || // Same for Apple Pay: row visibility depends on the geo/platform-gated
35719
36431
  // providers fetch — block the menu so the row doesn't pop in or out.
@@ -35735,12 +36447,6 @@ function DepositModal({
35735
36447
  /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("h3", { className: "uf-text-lg uf-font-semibold uf-text-foreground uf-mb-2", children: "No Tokens Available" }),
35736
36448
  /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { className: "uf-text-sm uf-text-muted-foreground uf-max-w-[280px]", children: "There are no supported tokens available from your current location." })
35737
36449
  ] });
35738
- } else if (isAddressValid === false) {
35739
- depositPrerequisiteBody = /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
35740
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("div", { className: "uf-w-16 uf-h-16 uf-rounded-full uf-bg-muted uf-flex uf-items-center uf-justify-center uf-mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(TriangleAlert, { className: "uf-w-8 uf-h-8 uf-text-muted-foreground" }) }),
35741
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("h3", { className: "uf-text-lg uf-font-semibold uf-text-foreground uf-mb-2", children: addressValidationMessages.unableToReceiveFunds }),
35742
- /* @__PURE__ */ (0, import_jsx_runtime80.jsx)("p", { className: "uf-text-sm uf-text-muted-foreground uf-max-w-[280px]", children: getAddressValidationErrorMessage(addressFailureCode, addressFailureMetadata) })
35743
- ] });
35744
36450
  } else {
35745
36451
  depositPrerequisiteBody = null;
35746
36452
  }
@@ -36234,6 +36940,7 @@ function DepositModal({
36234
36940
  title: modalTitle || "Deposit",
36235
36941
  showClose: !hideOverlay,
36236
36942
  onClose: handleClose,
36943
+ incident: activeIncident,
36237
36944
  showBalance: showBalanceHeader,
36238
36945
  balanceAddress: recipientAddress,
36239
36946
  balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" || destinationChainType === "n1" ? destinationChainType : void 0,
@@ -36253,6 +36960,7 @@ function DepositModal({
36253
36960
  showBack: showBackTransfer,
36254
36961
  onBack: handleBack,
36255
36962
  onClose: handleClose,
36963
+ incident: activeIncident,
36256
36964
  showBalance: showBalanceHeader,
36257
36965
  balanceAddress: recipientAddress,
36258
36966
  balanceChainType: destinationChainType === "ethereum" || destinationChainType === "solana" || destinationChainType === "bitcoin" || destinationChainType === "n1" ? destinationChainType : void 0,
@@ -36276,6 +36984,7 @@ function DepositModal({
36276
36984
  defaultSourceChainId,
36277
36985
  defaultSourceTokenAddress,
36278
36986
  defaultSourceSymbol,
36987
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
36279
36988
  depositConfirmationMode,
36280
36989
  onExecutionsChange: setDepositExecutions,
36281
36990
  onDepositSuccess: onDepositSuccessFor("transfer"),
@@ -36295,6 +37004,7 @@ function DepositModal({
36295
37004
  defaultSourceChainId,
36296
37005
  defaultSourceTokenAddress,
36297
37006
  defaultSourceSymbol,
37007
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
36298
37008
  depositConfirmationMode,
36299
37009
  onExecutionsChange: setDepositExecutions,
36300
37010
  onDepositSuccess: onDepositSuccessFor("transfer"),
@@ -36311,7 +37021,8 @@ function DepositModal({
36311
37021
  title: selectedExecution ? "Deposit Details" : depositTrackerTitle,
36312
37022
  showBack: showBackTracker,
36313
37023
  onBack: handleBack,
36314
- onClose: handleClose
37024
+ onClose: handleClose,
37025
+ incident: activeIncident
36315
37026
  }
36316
37027
  ),
36317
37028
  /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
@@ -36343,6 +37054,7 @@ function DepositModal({
36343
37054
  showBack: showBackCard,
36344
37055
  onBack: handleBack,
36345
37056
  onClose: handleClose,
37057
+ incident: activeIncident,
36346
37058
  badge: cardView === "quotes" ? { count: quotesCount } : void 0,
36347
37059
  showBalance: showBalanceHeader,
36348
37060
  balanceAddress: recipientAddress,
@@ -36379,7 +37091,8 @@ function DepositModal({
36379
37091
  wallets,
36380
37092
  assetCdnUrl: projectConfig?.asset_cdn_url,
36381
37093
  hideDepositFlowInfo,
36382
- hideDisplayDescription
37094
+ hideDisplayDescription,
37095
+ prefilledAmountUsd: normalizedPrefilledAmountUsd
36383
37096
  }
36384
37097
  ),
36385
37098
  depositPoweredByFooter
@@ -36391,7 +37104,8 @@ function DepositModal({
36391
37104
  title: payWithExchangeTitle,
36392
37105
  showBack: exchangeView === "pending" || sessionOpenedFromMenu,
36393
37106
  onBack: handleBack,
36394
- onClose: handleClose
37107
+ onClose: handleClose,
37108
+ incident: activeIncident
36395
37109
  }
36396
37110
  ),
36397
37111
  /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
@@ -36444,7 +37158,8 @@ function DepositModal({
36444
37158
  defaultSourceChainType,
36445
37159
  defaultSourceChainId,
36446
37160
  defaultSourceTokenAddress,
36447
- defaultSourceSymbol
37161
+ defaultSourceSymbol,
37162
+ prefilledAmountUsd: normalizedPrefilledAmountUsd
36448
37163
  }
36449
37164
  ),
36450
37165
  depositPoweredByFooter
@@ -36476,6 +37191,7 @@ function DepositModal({
36476
37191
  onDepositSuccess: onDepositSuccessFor("wallet_connect"),
36477
37192
  onDepositError: onDepositErrorFor("wallet_connect"),
36478
37193
  amountQuickSelect: browserWalletAmountQuickSelect,
37194
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
36479
37195
  onWalletDisconnect: handleWalletDisconnect,
36480
37196
  onWalletConnected: (info, dw) => {
36481
37197
  setBrowserWalletInfo({ ...info, depositWallet: dw });
@@ -36503,7 +37219,8 @@ function DepositModal({
36503
37219
  title: t8.bankTransfer.title,
36504
37220
  showBack: bankTransferView !== "providers" || sessionOpenedFromMenu,
36505
37221
  onBack: handleBack,
36506
- onClose: handleClose
37222
+ onClose: handleClose,
37223
+ incident: activeIncident
36507
37224
  }
36508
37225
  ),
36509
37226
  /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
@@ -36524,7 +37241,8 @@ function DepositModal({
36524
37241
  assetCdnUrl: projectConfig?.asset_cdn_url,
36525
37242
  onEvent,
36526
37243
  onDepositSuccess,
36527
- onDepositError
37244
+ onDepositError,
37245
+ prefilledAmountUsd: normalizedPrefilledAmountUsd
36528
37246
  }
36529
37247
  ),
36530
37248
  depositPoweredByFooter
@@ -36536,26 +37254,24 @@ function DepositModal({
36536
37254
  title: "Deposit with Link",
36537
37255
  showBack: stripeLinkStep !== "checkout" && stripeLinkStep !== "success",
36538
37256
  onBack: handleBack,
36539
- showClose: stripeLinkStep !== "checkout",
37257
+ incident: activeIncident,
37258
+ showClose: stripeLinkStep !== "checkout" && stripeLinkStep !== "auth",
36540
37259
  onClose: handleClose
36541
37260
  }
36542
37261
  ),
36543
37262
  /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
36544
37263
  isLoadingIp ? (
36545
- // Hold the geo decision until IP resolves so we don't mount
36546
- // PayWithStripeLink (which kicks off config/OAuth work) for a
36547
- // deep-link user who turns out to be outside the US.
37264
+ // Wait for location so the first config fetch is region-aware.
36548
37265
  /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(SkeletonButton, { variant: "with-icons" })
36549
37266
  ) : !showStripeLink ? (
36550
- // Stripe Link's crypto on-ramp is US-only. On a direct open
36551
- // (initialScreen="stripe_link") the row isn't in a menu to
36552
- // fall back to, so show a geo-restriction screen rather than
36553
- // the Link UI.
37267
+ // Direct opens (initialScreen="stripe_link") have no menu row
37268
+ // to fall back to, so render an unavailable state when backend
37269
+ // config resolves Stripe Link disabled/hidden.
36554
37270
  /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
36555
37271
  GeoRestrictionScreen,
36556
37272
  {
36557
37273
  methodName: t8.stripeLink.title,
36558
- message: "Pay with Link is only available in the US."
37274
+ message: t8.stripeLink.unavailableInRegionMessage
36559
37275
  }
36560
37276
  )
36561
37277
  ) : /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(
@@ -36567,6 +37283,8 @@ function DepositModal({
36567
37283
  destinationChainType,
36568
37284
  destinationChainId,
36569
37285
  destinationTokenAddress,
37286
+ countryCode: userIpInfo?.alpha2,
37287
+ subdivisionCode: userIpInfo?.subdivisionCode ?? void 0,
36570
37288
  wallets,
36571
37289
  email: userEmail,
36572
37290
  iconUrl: projectConfig?.asset_cdn_url ? `${projectConfig.asset_cdn_url}/api/public/icons/onramps/svg/link.svg` : void 0,
@@ -36586,7 +37304,8 @@ function DepositModal({
36586
37304
  title: cashAppView !== "amount" && cashAppAmount ? `Pay $${cashAppAmount} via Cash App` : "Pay with Cash App",
36587
37305
  showBack: cashAppView !== "amount" || sessionOpenedFromMenu,
36588
37306
  onBack: handleBack,
36589
- onClose: handleClose
37307
+ onClose: handleClose,
37308
+ incident: activeIncident
36590
37309
  }
36591
37310
  ),
36592
37311
  /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
@@ -36606,6 +37325,7 @@ function DepositModal({
36606
37325
  onEvent,
36607
37326
  onDepositSuccess: onDepositSuccessFor("cashapp"),
36608
37327
  onDepositError: onDepositErrorFor("cashapp"),
37328
+ prefilledAmountUsd: normalizedPrefilledAmountUsd,
36609
37329
  wallets
36610
37330
  }
36611
37331
  ),
@@ -36621,7 +37341,8 @@ function DepositModal({
36621
37341
  const handled = applePayHandleRef.current?.requestBack() ?? false;
36622
37342
  if (!handled) handleBack();
36623
37343
  },
36624
- onClose: handleClose
37344
+ onClose: handleClose,
37345
+ incident: activeIncident
36625
37346
  }
36626
37347
  ),
36627
37348
  /* @__PURE__ */ (0, import_jsx_runtime80.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
@@ -36664,7 +37385,7 @@ function DepositModal({
36664
37385
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["succeeded", "expired", "refunded", "canceled"]);
36665
37386
  function usePaymentIntent(params) {
36666
37387
  const { clientSecret, publishableKey, enabled = true, pollingInterval = 3e3 } = params;
36667
- return (0, import_react_query19.useQuery)({
37388
+ return (0, import_react_query21.useQuery)({
36668
37389
  queryKey: ["unifold", "paymentIntent", clientSecret, publishableKey],
36669
37390
  queryFn: () => retrievePaymentIntent(clientSecret, publishableKey),
36670
37391
  enabled: enabled && !!clientSecret && !!publishableKey,
@@ -36736,6 +37457,7 @@ function CheckoutModal({
36736
37457
  modalTitle,
36737
37458
  enableTransferCrypto,
36738
37459
  enableConnectWallet,
37460
+ enableIncidentBanner = false,
36739
37461
  defaultSourceChainType,
36740
37462
  defaultSourceChainId,
36741
37463
  defaultSourceTokenAddress,
@@ -36807,6 +37529,16 @@ function CheckoutModal({
36807
37529
  });
36808
37530
  const showTransferCrypto = enableTransferCrypto ?? projectConfig?.transfer_crypto?.enabled ?? true;
36809
37531
  const showConnectWallet = enableConnectWallet ?? projectConfig?.connect_wallet?.enabled ?? true;
37532
+ const { incident: publicIncident } = usePublicIncident({
37533
+ publishableKey,
37534
+ enabled: open && enableIncidentBanner
37535
+ });
37536
+ const activeIncident = enableIncidentBanner && publicIncident?.enabled && (publicIncident.messages?.length ?? 0) > 0 ? {
37537
+ enabled: true,
37538
+ messages: publicIncident.messages,
37539
+ severity: publicIncident.severity,
37540
+ statusPageUrl: publicIncident.status_page_url
37541
+ } : void 0;
36810
37542
  (0, import_react34.useEffect)(() => {
36811
37543
  if (view === "transfer" && !showTransferCrypto) {
36812
37544
  setView("main");
@@ -37108,7 +37840,15 @@ function CheckoutModal({
37108
37840
  {
37109
37841
  className: view === "wallet_connect" ? "uf-flex uf-min-h-0 uf-flex-col" : void 0,
37110
37842
  children: view === "main" ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)(import_jsx_runtime81.Fragment, { children: [
37111
- /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(DepositHeader, { title: modalTitle || "Checkout", showClose: true, onClose: handleClose }),
37843
+ /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
37844
+ DepositHeader,
37845
+ {
37846
+ title: modalTitle || "Checkout",
37847
+ showClose: true,
37848
+ onClose: handleClose,
37849
+ incident: activeIncident
37850
+ }
37851
+ ),
37112
37852
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
37113
37853
  piLoading ? /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "uf-space-y-3", children: [
37114
37854
  /* @__PURE__ */ (0, import_jsx_runtime81.jsx)(
@@ -37206,7 +37946,8 @@ function CheckoutModal({
37206
37946
  title: modalTitle || "Checkout",
37207
37947
  showBack: true,
37208
37948
  onBack: handleBack,
37209
- onClose: handleClose
37949
+ onClose: handleClose,
37950
+ incident: activeIncident
37210
37951
  }
37211
37952
  ),
37212
37953
  /* @__PURE__ */ (0, import_jsx_runtime81.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-1.5", children: [
@@ -37305,7 +38046,7 @@ function CheckoutModal({
37305
38046
  userId: paymentIntent.user_id || "",
37306
38047
  publishableKey,
37307
38048
  clientSecret,
37308
- prefillAmountUsd: remainingAmountUsd,
38049
+ prefilledAmountUsd: remainingAmountUsd,
37309
38050
  checkoutAmountUsd: paymentIntent.amount_usd,
37310
38051
  checkoutReceivedUsd: paymentIntent.amount_received_usd,
37311
38052
  checkoutDestination: {
@@ -37366,7 +38107,7 @@ function CheckoutModal({
37366
38107
  ) }) });
37367
38108
  }
37368
38109
  function useSupportedDestinationTokens(publishableKey, enabled = true) {
37369
- return (0, import_react_query20.useQuery)({
38110
+ return (0, import_react_query22.useQuery)({
37370
38111
  queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
37371
38112
  queryFn: () => getSupportedDestinationTokens(publishableKey),
37372
38113
  staleTime: 1e3 * 60 * 5,
@@ -37376,6 +38117,7 @@ function useSupportedDestinationTokens(publishableKey, enabled = true) {
37376
38117
  enabled
37377
38118
  });
37378
38119
  }
38120
+ var STORAGE_KEY3 = "unifold_last_withdraw_to_token";
37379
38121
  function useDefaultDestinationToken({
37380
38122
  destinationTokens,
37381
38123
  defaultDestinationChainType,
@@ -37388,7 +38130,8 @@ function useDefaultDestinationToken({
37388
38130
  defaultChainType: defaultDestinationChainType,
37389
38131
  defaultChainId: defaultDestinationChainId,
37390
38132
  defaultTokenAddress: defaultDestinationTokenAddress,
37391
- defaultSymbol: defaultDestinationSymbol
38133
+ defaultSymbol: defaultDestinationSymbol,
38134
+ storageKey: STORAGE_KEY3
37392
38135
  });
37393
38136
  }
37394
38137
  function useSourceTokenValidation(params) {
@@ -37401,7 +38144,7 @@ function useSourceTokenValidation(params) {
37401
38144
  enabled = true
37402
38145
  } = params;
37403
38146
  const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
37404
- return (0, import_react_query21.useQuery)({
38147
+ return (0, import_react_query23.useQuery)({
37405
38148
  queryKey: [
37406
38149
  "unifold",
37407
38150
  "sourceTokenValidation",
@@ -37450,7 +38193,7 @@ function useSourceTokenValidation(params) {
37450
38193
  function useAddressBalance(params) {
37451
38194
  const { address, chainType, chainId, tokenAddress, publishableKey, enabled = true } = params;
37452
38195
  const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
37453
- return (0, import_react_query22.useQuery)({
38196
+ return (0, import_react_query24.useQuery)({
37454
38197
  queryKey: [
37455
38198
  "unifold",
37456
38199
  "addressBalance",
@@ -37506,7 +38249,7 @@ function useAddressBalance(params) {
37506
38249
  }
37507
38250
  function useExecutions(userId, publishableKey, options) {
37508
38251
  const actionType = options?.actionType ?? ActionType.Deposit;
37509
- return (0, import_react_query23.useQuery)({
38252
+ return (0, import_react_query25.useQuery)({
37510
38253
  queryKey: ["unifold", "executions", actionType, userId, publishableKey],
37511
38254
  queryFn: () => queryExecutions(userId, publishableKey, actionType),
37512
38255
  enabled: (options?.enabled ?? true) && !!userId,
@@ -37832,7 +38575,7 @@ function useVerifyRecipientAddress(params) {
37832
38575
  } = params;
37833
38576
  const trimmedAddress = recipientAddress?.trim() || "";
37834
38577
  const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
37835
- return (0, import_react_query24.useQuery)({
38578
+ return (0, import_react_query26.useQuery)({
37836
38579
  queryKey: [
37837
38580
  "unifold",
37838
38581
  "verifyRecipientAddress",
@@ -37871,7 +38614,7 @@ function useGetDepositAddress(params) {
37871
38614
  enabled = true
37872
38615
  } = params;
37873
38616
  const canFire = !!userId && !!recipientAddress && !!destinationChainType && !!destinationChainId && !!destinationTokenAddress;
37874
- return (0, import_react_query25.useQuery)({
38617
+ return (0, import_react_query27.useQuery)({
37875
38618
  queryKey: [
37876
38619
  "unifold",
37877
38620
  "getDepositAddress",
@@ -38062,6 +38805,9 @@ function WithdrawForm({
38062
38805
  if (isDebouncing || isVerifyingAddress) return null;
38063
38806
  if (verifyError) return t10.invalidAddress;
38064
38807
  if (addressVerification && !addressVerification.valid) {
38808
+ if (addressVerification.message && addressVerification.message.trim().length > 0) {
38809
+ return addressVerification.message;
38810
+ }
38065
38811
  if (addressVerification.failure_code === "account_not_found")
38066
38812
  return `Account not found on ${selectedChain?.chain_name}`;
38067
38813
  if (addressVerification.failure_code === "not_opted_in")
@@ -39321,6 +40067,7 @@ function UnifoldProvider2({
39321
40067
  const [isWithdrawOpen, setIsWithdrawOpen] = (0, import_react41.useState)(false);
39322
40068
  const [withdrawConfig, setWithdrawConfig] = (0, import_react41.useState)(null);
39323
40069
  const [resolvedTheme, setResolvedTheme] = import_react41.default.useState("dark");
40070
+ const incidentBannerEnabled = config?.notifications?.incidentBanner;
39324
40071
  (0, import_react41.useEffect)(() => {
39325
40072
  if (publishableKey) {
39326
40073
  setApiConfig({ publishableKey });
@@ -39618,6 +40365,7 @@ function UnifoldProvider2({
39618
40365
  publishableKey,
39619
40366
  enableTransferCrypto: config?.enableTransferCrypto,
39620
40367
  enableConnectWallet: config?.enableConnectWallet,
40368
+ enableIncidentBanner: incidentBannerEnabled,
39621
40369
  defaultSourceChainType: checkoutConfig.defaultSourceChainType,
39622
40370
  defaultSourceChainId: checkoutConfig.defaultSourceChainId,
39623
40371
  defaultSourceTokenAddress: checkoutConfig.defaultSourceTokenAddress,
@@ -39671,6 +40419,7 @@ function UnifoldProvider2({
39671
40419
  defaultSourceChainId: depositConfig.defaultSourceChainId,
39672
40420
  defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
39673
40421
  defaultSourceSymbol: depositConfig.defaultSourceSymbol,
40422
+ prefilledAmountUsd: depositConfig.prefilledAmountUsd,
39674
40423
  userEmail: depositConfig.user?.email,
39675
40424
  depositConfirmationMode: depositConfig.depositConfirmationMode ?? "auto_ui",
39676
40425
  hideDepositTracker: config?.hideDepositTracker,
@@ -39684,6 +40433,7 @@ function UnifoldProvider2({
39684
40433
  enableConnectExchange: config?.enableConnectExchange,
39685
40434
  enableCashApp: config?.enableCashApp,
39686
40435
  enableStripeLink: config?.enableStripeLink,
40436
+ enableIncidentBanner: incidentBannerEnabled,
39687
40437
  enableApplePay: config?.enableApplePay,
39688
40438
  applePayTitle: config?.applePayTitle,
39689
40439
  applePaySubTitle: config?.applePaySubTitle,