@nowramp/form 0.2.6 → 0.2.7
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +181 -178
- package/dist/index.js.map +1 -1
- package/dist/nowramp-form.iife.js +8 -8
- package/dist/nowramp-form.iife.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
})();
|
|
11
11
|
import { jsx as e, jsxs as i, Fragment as G } from "react/jsx-runtime";
|
|
12
12
|
import ke, { useState as w, useRef as I, useCallback as P, useEffect as U, useMemo as j, useReducer as an, useContext as ga, createContext as xa } from "react";
|
|
13
|
-
import { RampApi as
|
|
13
|
+
import { RampApi as xt } from "@nowramp/sdk";
|
|
14
14
|
import { createPortal as oa } from "react-dom";
|
|
15
15
|
function nn(t, a, n) {
|
|
16
16
|
const [r, o] = w(null), [l, d] = w(!0), [c, u] = w(null), s = I(null);
|
|
17
|
-
(!s.current || s.current !== t) && (s.current = new
|
|
17
|
+
(!s.current || s.current !== t) && (s.current = new xt({ apiKey: "", ...t }));
|
|
18
18
|
const h = P(async () => {
|
|
19
19
|
if (!t.projectId) {
|
|
20
20
|
u(new Error("projectId is required")), d(!1);
|
|
@@ -38,7 +38,7 @@ function nn(t, a, n) {
|
|
|
38
38
|
}
|
|
39
39
|
function rn(t, a) {
|
|
40
40
|
const [n, r] = w(null), [o, l] = w(!1), [d, c] = w(null), u = I(null), s = I(""), h = `${t.apiUrl}|${t.projectId}`;
|
|
41
|
-
(!u.current || s.current !== h) && (u.current = new
|
|
41
|
+
(!u.current || s.current !== h) && (u.current = new xt({ apiKey: "", ...t }), s.current = h);
|
|
42
42
|
const m = I(0);
|
|
43
43
|
U(() => {
|
|
44
44
|
const g = ++m.current;
|
|
@@ -72,7 +72,7 @@ function rn(t, a) {
|
|
|
72
72
|
}
|
|
73
73
|
function on(t) {
|
|
74
74
|
const [a, n] = w(null), [r, o] = w(!1), [l, d] = w(null), c = I(null), u = I(""), s = `${t.apiUrl}|${t.projectId}`;
|
|
75
|
-
(!c.current || u.current !== s) && (c.current = new
|
|
75
|
+
(!c.current || u.current !== s) && (c.current = new xt({ apiKey: "", ...t }), u.current = s);
|
|
76
76
|
const h = P(async (f) => {
|
|
77
77
|
o(!0), d(null);
|
|
78
78
|
try {
|
|
@@ -91,7 +91,7 @@ function on(t) {
|
|
|
91
91
|
}
|
|
92
92
|
function ln(t, a, n) {
|
|
93
93
|
const [r, o] = w(null), [l, d] = w(!1), [c, u] = w(null), s = I(null);
|
|
94
|
-
s.current || (s.current = new
|
|
94
|
+
s.current || (s.current = new xt({ apiKey: "", projectId: "", ...t }));
|
|
95
95
|
const h = P(async () => {
|
|
96
96
|
if (a) {
|
|
97
97
|
d(!0), u(null);
|
|
@@ -120,7 +120,7 @@ function ln(t, a, n) {
|
|
|
120
120
|
return () => clearInterval(f);
|
|
121
121
|
}, [a, n == null ? void 0 : n.pollInterval, r == null ? void 0 : r.status, h]), { status: r, loading: l, error: c, refetch: h };
|
|
122
122
|
}
|
|
123
|
-
const
|
|
123
|
+
const yt = [
|
|
124
124
|
{ code: "ad", name: "Andorra", defaultFiat: "EUR" },
|
|
125
125
|
{ code: "ae", name: "United Arab Emirates", defaultFiat: "AED" },
|
|
126
126
|
{ code: "af", name: "Afghanistan", defaultFiat: "USD" },
|
|
@@ -313,21 +313,21 @@ const ft = [
|
|
|
313
313
|
{ code: "zm", name: "Zambia", defaultFiat: "USD" },
|
|
314
314
|
{ code: "zw", name: "Zimbabwe", defaultFiat: "USD" }
|
|
315
315
|
], Ot = Object.fromEntries(
|
|
316
|
-
|
|
316
|
+
yt.map((t) => [t.code, t])
|
|
317
317
|
);
|
|
318
318
|
function Mt(t, a) {
|
|
319
319
|
if (!t) return "USD";
|
|
320
320
|
const n = Ot[t.toLowerCase()], r = (n == null ? void 0 : n.defaultFiat) || "USD";
|
|
321
321
|
return !a || a.length === 0 || a.includes(r) ? r : a.includes("USD") ? "USD" : a[0] || "USD";
|
|
322
322
|
}
|
|
323
|
-
const
|
|
324
|
-
function Kt(t, a, n =
|
|
323
|
+
const vt = !0;
|
|
324
|
+
function Kt(t, a, n = vt) {
|
|
325
325
|
return t === void 0 || a === void 0 ? n : t.length === 0 || a.length === 0 ? !1 : t.some((r) => a.includes(r));
|
|
326
326
|
}
|
|
327
|
-
function cn(t, a, n =
|
|
327
|
+
function cn(t, a, n = vt) {
|
|
328
328
|
return t.filter((r) => Kt(r.providers, a, n));
|
|
329
329
|
}
|
|
330
|
-
function sn(t, a, n =
|
|
330
|
+
function sn(t, a, n = vt) {
|
|
331
331
|
const r = [];
|
|
332
332
|
for (const o of t) {
|
|
333
333
|
const l = o.networks.filter(
|
|
@@ -339,7 +339,7 @@ function sn(t, a, n = xt) {
|
|
|
339
339
|
}
|
|
340
340
|
return r;
|
|
341
341
|
}
|
|
342
|
-
function dn(t, a, n, r =
|
|
342
|
+
function dn(t, a, n, r = vt) {
|
|
343
343
|
return n ? t.filter(
|
|
344
344
|
(o) => o.supportedFiats.includes(n) && Kt(o.providers, a, r)
|
|
345
345
|
) : [];
|
|
@@ -541,7 +541,7 @@ function xn(t) {
|
|
|
541
541
|
statusPollInterval: K = 5e3,
|
|
542
542
|
onComplete: z,
|
|
543
543
|
onError: J,
|
|
544
|
-
children:
|
|
544
|
+
children: oe
|
|
545
545
|
} = t, q = j(() => ({ apiUrl: r, projectId: n }), [r, n]), te = h || (s === "BTC" ? "bitcoin" : s ? s.toLowerCase() : ""), be = l === "sell", ae = be ? !!f : !!m, C = (be ? !!(ae && s && te) : !!(ae && s && te && g)) && k ? "confirm" : "amount", F = m || (l === "buy" ? "250" : ""), [p, D] = an(gn, {
|
|
546
546
|
...va,
|
|
547
547
|
step: C,
|
|
@@ -556,92 +556,92 @@ function xn(t) {
|
|
|
556
556
|
// If defaultCountry is provided, set it immediately with 'manual' source to skip auto-detection
|
|
557
557
|
...A ? { country: A.toLowerCase(), countrySource: "manual" } : {}
|
|
558
558
|
}), E = p.flowType === "sell", {
|
|
559
|
-
config:
|
|
559
|
+
config: S,
|
|
560
560
|
loading: ne,
|
|
561
561
|
error: pe
|
|
562
562
|
} = nn(q, p.flowType, p.country || void 0), Se = I(!1);
|
|
563
563
|
ke.useEffect(() => {
|
|
564
564
|
var B, M;
|
|
565
|
-
if (Se.current || !(
|
|
565
|
+
if (Se.current || !(S != null && S.detectedCountry) || p.country) return;
|
|
566
566
|
Se.current = !0;
|
|
567
|
-
const v =
|
|
567
|
+
const v = S.detectedCountry.toLowerCase();
|
|
568
568
|
D({ type: "SET_COUNTRY_AUTO", country: v });
|
|
569
|
-
const R = (B =
|
|
569
|
+
const R = (B = S.fiats) == null ? void 0 : B.map((_) => _.code), T = Mt(v, R);
|
|
570
570
|
T !== p.fiatCurrency && !((M = y == null ? void 0 : y.sourceCurrency) != null && M.locked) && !a.current && D({ type: "SET_FIAT_CURRENCY", currency: T });
|
|
571
|
-
}, [
|
|
571
|
+
}, [S, p.country, p.fiatCurrency, y]);
|
|
572
572
|
const Te = I(!1);
|
|
573
573
|
ke.useEffect(() => {
|
|
574
574
|
var T, B;
|
|
575
|
-
if (Te.current || !A || !((T =
|
|
575
|
+
if (Te.current || !A || !((T = S == null ? void 0 : S.fiats) != null && T.length)) return;
|
|
576
576
|
Te.current = !0;
|
|
577
|
-
const v =
|
|
577
|
+
const v = S.fiats.map((M) => M.code), R = Mt(A, v);
|
|
578
578
|
R !== p.fiatCurrency && !((B = y == null ? void 0 : y.sourceCurrency) != null && B.locked) && !a.current && D({ type: "SET_FIAT_CURRENCY", currency: R });
|
|
579
|
-
}, [A,
|
|
579
|
+
}, [A, S, p.fiatCurrency, y]);
|
|
580
580
|
const he = I(p.country);
|
|
581
581
|
ke.useEffect(() => {
|
|
582
582
|
var T, B;
|
|
583
|
-
if (p.country === he.current || (he.current = p.country, p.countrySource === "manual" && (_e.current = !1), p.countrySource !== "manual") || !((T =
|
|
584
|
-
const v =
|
|
583
|
+
if (p.country === he.current || (he.current = p.country, p.countrySource === "manual" && (_e.current = !1), p.countrySource !== "manual") || !((T = S == null ? void 0 : S.fiats) != null && T.length)) return;
|
|
584
|
+
const v = S.fiats.map((M) => M.code), R = Mt(p.country, v);
|
|
585
585
|
R !== p.fiatCurrency && !((B = y == null ? void 0 : y.sourceCurrency) != null && B.locked) && D({ type: "SET_FIAT_CURRENCY", currency: R });
|
|
586
|
-
}, [p.country, p.countrySource,
|
|
587
|
-
const
|
|
586
|
+
}, [p.country, p.countrySource, S, p.fiatCurrency, y]);
|
|
587
|
+
const ie = I(p.fiatCurrency);
|
|
588
588
|
ke.useEffect(() => {
|
|
589
589
|
var B;
|
|
590
|
-
if (p.fiatCurrency ===
|
|
591
|
-
const v =
|
|
590
|
+
if (p.fiatCurrency === ie.current || (ie.current = p.fiatCurrency, E || !((B = S == null ? void 0 : S.fiats) != null && B.length) || !p.fiatAmount)) return;
|
|
591
|
+
const v = S.fiats.find((M) => M.code === p.fiatCurrency);
|
|
592
592
|
if (!(v != null && v.minAmount)) return;
|
|
593
593
|
const R = parseFloat(p.fiatAmount), T = parseFloat(v.minAmount);
|
|
594
594
|
!isNaN(R) && !isNaN(T) && R < T && D({ type: "SET_FIAT_AMOUNT", amount: String(Math.ceil(T)) });
|
|
595
|
-
}, [p.fiatCurrency, p.fiatAmount,
|
|
596
|
-
const { availableFiats:
|
|
595
|
+
}, [p.fiatCurrency, p.fiatAmount, S, E]);
|
|
596
|
+
const { availableFiats: le, availableCryptos: X, availablePaymentMethods: fe } = j(() => {
|
|
597
597
|
var T, B, M;
|
|
598
|
-
if (!
|
|
598
|
+
if (!S)
|
|
599
599
|
return { availableFiats: [], availableCryptos: [], availablePaymentMethods: [] };
|
|
600
600
|
let v;
|
|
601
601
|
if (p.cryptoCurrency && p.network) {
|
|
602
|
-
const _ = (T =
|
|
602
|
+
const _ = (T = S.cryptos) == null ? void 0 : T.find((ge) => ge.code === p.cryptoCurrency), ue = (B = _ == null ? void 0 : _.networks) == null ? void 0 : B.find((ge) => ge.id === p.network);
|
|
603
603
|
!_ || !ue ? v = [] : v = ue.providers;
|
|
604
604
|
}
|
|
605
605
|
let R;
|
|
606
606
|
if (p.fiatCurrency) {
|
|
607
|
-
const _ = (M =
|
|
607
|
+
const _ = (M = S.fiats) == null ? void 0 : M.find((ue) => ue.code === p.fiatCurrency);
|
|
608
608
|
_ ? R = _.providers : R = [];
|
|
609
609
|
}
|
|
610
610
|
return {
|
|
611
|
-
availableFiats: cn(
|
|
612
|
-
availableCryptos: sn(
|
|
611
|
+
availableFiats: cn(S.fiats ?? [], v),
|
|
612
|
+
availableCryptos: sn(S.cryptos ?? [], R),
|
|
613
613
|
availablePaymentMethods: dn(
|
|
614
|
-
|
|
614
|
+
S.paymentMethods ?? [],
|
|
615
615
|
v,
|
|
616
616
|
p.fiatCurrency
|
|
617
617
|
)
|
|
618
618
|
};
|
|
619
|
-
}, [
|
|
619
|
+
}, [S, p.cryptoCurrency, p.network, p.fiatCurrency]), Qe = j(() => {
|
|
620
620
|
var v, R, T;
|
|
621
|
-
return ne || !
|
|
622
|
-
|
|
621
|
+
return ne || !S ? !1 : mn(
|
|
622
|
+
S,
|
|
623
623
|
{ cryptoCurrency: p.cryptoCurrency, network: p.network, fiatCurrency: p.fiatCurrency },
|
|
624
624
|
{
|
|
625
625
|
cryptoLocked: !!((v = y == null ? void 0 : y.destinationCurrency) != null && v.locked),
|
|
626
626
|
networkLocked: !!((R = y == null ? void 0 : y.network) != null && R.locked),
|
|
627
627
|
fiatLocked: !!((T = y == null ? void 0 : y.sourceCurrency) != null && T.locked)
|
|
628
628
|
},
|
|
629
|
-
{ availableFiats:
|
|
629
|
+
{ availableFiats: le, availableCryptos: X, availablePaymentMethods: fe }
|
|
630
630
|
);
|
|
631
631
|
}, [
|
|
632
632
|
ne,
|
|
633
|
-
|
|
633
|
+
S,
|
|
634
634
|
y,
|
|
635
635
|
p.cryptoCurrency,
|
|
636
636
|
p.network,
|
|
637
637
|
p.fiatCurrency,
|
|
638
|
-
|
|
638
|
+
le,
|
|
639
639
|
X,
|
|
640
640
|
fe
|
|
641
641
|
]);
|
|
642
642
|
ke.useEffect(() => {
|
|
643
643
|
var R, T, B;
|
|
644
|
-
if (ne ||
|
|
644
|
+
if (ne || le.length === 0 && X.length === 0) return;
|
|
645
645
|
const v = un(
|
|
646
646
|
{
|
|
647
647
|
cryptoCurrency: p.cryptoCurrency,
|
|
@@ -649,7 +649,7 @@ function xn(t) {
|
|
|
649
649
|
fiatCurrency: p.fiatCurrency,
|
|
650
650
|
paymentMethodId: p.paymentMethodId
|
|
651
651
|
},
|
|
652
|
-
{ availableFiats:
|
|
652
|
+
{ availableFiats: le, availableCryptos: X, availablePaymentMethods: fe },
|
|
653
653
|
{
|
|
654
654
|
cryptoLocked: !!((R = y == null ? void 0 : y.destinationCurrency) != null && R.locked),
|
|
655
655
|
networkLocked: !!((T = y == null ? void 0 : y.network) != null && T.locked),
|
|
@@ -659,7 +659,7 @@ function xn(t) {
|
|
|
659
659
|
v && (v.cryptoCurrency !== void 0 && D({ type: "SET_CRYPTO_CURRENCY", currency: v.cryptoCurrency }), v.network !== void 0 && D({ type: "SET_NETWORK", network: v.network }), v.fiatCurrency !== void 0 && D({ type: "SET_FIAT_CURRENCY", currency: v.fiatCurrency }), v.paymentMethodId !== void 0 && D({ type: "SET_PAYMENT_METHOD", methodId: v.paymentMethodId }));
|
|
660
660
|
}, [
|
|
661
661
|
ne,
|
|
662
|
-
|
|
662
|
+
le,
|
|
663
663
|
X,
|
|
664
664
|
fe,
|
|
665
665
|
p.cryptoCurrency,
|
|
@@ -669,22 +669,22 @@ function xn(t) {
|
|
|
669
669
|
y,
|
|
670
670
|
D
|
|
671
671
|
]);
|
|
672
|
-
const
|
|
672
|
+
const ce = j(() => {
|
|
673
673
|
if (E) {
|
|
674
674
|
if (!p.cryptoAmount) return null;
|
|
675
675
|
const M = parseFloat(p.cryptoAmount);
|
|
676
676
|
return isNaN(M) || M <= 0 ? "Enter a valid amount" : null;
|
|
677
677
|
}
|
|
678
|
-
if (!
|
|
678
|
+
if (!S || !p.fiatAmount) return null;
|
|
679
679
|
const v = parseFloat(p.fiatAmount);
|
|
680
680
|
if (isNaN(v)) return null;
|
|
681
|
-
const R =
|
|
681
|
+
const R = S.fiats.find((M) => M.code === p.fiatCurrency);
|
|
682
682
|
if (!R) return null;
|
|
683
683
|
const T = parseFloat(R.minAmount), B = parseFloat(R.maxAmount);
|
|
684
684
|
return !isNaN(T) && v < T ? `Minimum amount is ${R.minAmount} ${p.fiatCurrency}` : !isNaN(B) && v > B ? `Maximum amount is ${R.maxAmount} ${p.fiatCurrency}` : null;
|
|
685
|
-
}, [
|
|
685
|
+
}, [S, p.fiatAmount, p.fiatCurrency, p.cryptoAmount, E]), ye = j(() => {
|
|
686
686
|
const v = E ? !!p.cryptoAmount : !!p.fiatAmount;
|
|
687
|
-
return !
|
|
687
|
+
return !S || !v || !p.fiatCurrency || !p.cryptoCurrency || !p.network || ce || S.detectedCountry && p.countrySource === "" && !A ? null : {
|
|
688
688
|
fiatCurrency: p.fiatCurrency,
|
|
689
689
|
...E ? { cryptoAmount: p.cryptoAmount } : { fiatAmount: p.fiatAmount },
|
|
690
690
|
cryptoCurrency: p.cryptoCurrency,
|
|
@@ -693,11 +693,11 @@ function xn(t) {
|
|
|
693
693
|
country: p.country || void 0,
|
|
694
694
|
orderType: p.flowType
|
|
695
695
|
};
|
|
696
|
-
}, [
|
|
696
|
+
}, [S, p.fiatCurrency, p.fiatAmount, p.cryptoAmount, p.cryptoCurrency, p.network, p.paymentMethodId, p.country, p.countrySource, ce, E, p.flowType, A]), {
|
|
697
697
|
quotes: $,
|
|
698
698
|
loading: Ke,
|
|
699
699
|
error: ze,
|
|
700
|
-
refetch:
|
|
700
|
+
refetch: Ct
|
|
701
701
|
} = rn(q, ye), se = pn(Ke, $, ye), _e = I(!1);
|
|
702
702
|
ke.useEffect(() => {
|
|
703
703
|
var v;
|
|
@@ -705,12 +705,12 @@ function xn(t) {
|
|
|
705
705
|
}, [$, Ke, ze, ye, p.countrySource, p.fiatCurrency]);
|
|
706
706
|
const {
|
|
707
707
|
order: Le,
|
|
708
|
-
loading:
|
|
708
|
+
loading: bt,
|
|
709
709
|
error: de,
|
|
710
710
|
createOrder: V
|
|
711
711
|
} = on(q), lt = 15e3, {
|
|
712
712
|
status: Z,
|
|
713
|
-
loading:
|
|
713
|
+
loading: St
|
|
714
714
|
} = ln(
|
|
715
715
|
{ apiUrl: r },
|
|
716
716
|
(Le == null ? void 0 : Le.orderId) ?? null,
|
|
@@ -722,7 +722,7 @@ function xn(t) {
|
|
|
722
722
|
const v = pe || de;
|
|
723
723
|
v && J && J(v);
|
|
724
724
|
}, [pe, de, J]);
|
|
725
|
-
const Fe = k || (
|
|
725
|
+
const Fe = k || (S == null ? void 0 : S.defaultGateway) || null, ct = j(() => {
|
|
726
726
|
if (!se || !($ != null && $.unavailableGateways)) return null;
|
|
727
727
|
const v = $.preferredGatewayId || Fe;
|
|
728
728
|
return hn($.unavailableGateways, v);
|
|
@@ -761,16 +761,16 @@ function xn(t) {
|
|
|
761
761
|
}
|
|
762
762
|
}, [p, V, E, N]), tt = P((v) => {
|
|
763
763
|
D({ type: "SET_STEP", step: v });
|
|
764
|
-
}, []),
|
|
764
|
+
}, []), wt = P(() => {
|
|
765
765
|
const v = ["confirm", "amount", "quotes", "wallet", "checkout", "processing", "complete"], R = v.indexOf(p.step);
|
|
766
766
|
R > 0 && D({ type: "SET_STEP", step: v[R - 1] });
|
|
767
|
-
}, [p.step, E]),
|
|
767
|
+
}, [p.step, E]), kt = j(() => {
|
|
768
768
|
const v = E ? !!p.cryptoAmount : !!p.fiatAmount;
|
|
769
769
|
switch (p.step) {
|
|
770
770
|
case "confirm":
|
|
771
|
-
return !!(v && p.cryptoCurrency && p.network && p.walletAddress && !
|
|
771
|
+
return !!(v && p.cryptoCurrency && p.network && p.walletAddress && !ce);
|
|
772
772
|
case "amount":
|
|
773
|
-
return !!(v && p.cryptoCurrency && p.network && !
|
|
773
|
+
return !!(v && p.cryptoCurrency && p.network && !ce);
|
|
774
774
|
case "quotes":
|
|
775
775
|
return !!p.selectedQuote;
|
|
776
776
|
case "wallet":
|
|
@@ -778,10 +778,10 @@ function xn(t) {
|
|
|
778
778
|
default:
|
|
779
779
|
return !1;
|
|
780
780
|
}
|
|
781
|
-
}, [p,
|
|
781
|
+
}, [p, ce, E]), st = {
|
|
782
782
|
apiConfig: q,
|
|
783
783
|
assetBaseUrl: o,
|
|
784
|
-
config:
|
|
784
|
+
config: S,
|
|
785
785
|
configLoading: ne,
|
|
786
786
|
configError: pe,
|
|
787
787
|
state: p,
|
|
@@ -789,27 +789,27 @@ function xn(t) {
|
|
|
789
789
|
quotes: $,
|
|
790
790
|
quotesLoading: Ke,
|
|
791
791
|
quotesError: ze,
|
|
792
|
-
fetchQuotes:
|
|
792
|
+
fetchQuotes: Ct,
|
|
793
793
|
order: Le,
|
|
794
|
-
orderLoading:
|
|
794
|
+
orderLoading: bt,
|
|
795
795
|
orderError: de,
|
|
796
796
|
createOrder: Ue,
|
|
797
797
|
orderStatus: Z,
|
|
798
|
-
orderStatusLoading:
|
|
798
|
+
orderStatusLoading: St,
|
|
799
799
|
fieldLocks: y || null,
|
|
800
800
|
defaultGateway: Fe,
|
|
801
|
-
availableFiats:
|
|
801
|
+
availableFiats: le,
|
|
802
802
|
availableCryptos: X,
|
|
803
803
|
availablePaymentMethods: fe,
|
|
804
804
|
selectionUnsupported: Qe,
|
|
805
805
|
quotesEmpty: se,
|
|
806
806
|
bestUnavailableReason: ct,
|
|
807
|
-
amountError:
|
|
807
|
+
amountError: ce,
|
|
808
808
|
goToStep: tt,
|
|
809
|
-
goBack:
|
|
810
|
-
canProceed:
|
|
809
|
+
goBack: wt,
|
|
810
|
+
canProceed: kt
|
|
811
811
|
};
|
|
812
|
-
return /* @__PURE__ */ e(Ca.Provider, { value: st, children:
|
|
812
|
+
return /* @__PURE__ */ e(Ca.Provider, { value: st, children: oe });
|
|
813
813
|
}
|
|
814
814
|
function Xe() {
|
|
815
815
|
const t = ga(Ca);
|
|
@@ -2299,14 +2299,14 @@ function Un(t, a = "") {
|
|
|
2299
2299
|
const n = Fn[t] || "us";
|
|
2300
2300
|
return `${a}/flags/${n}.svg`;
|
|
2301
2301
|
}
|
|
2302
|
-
function
|
|
2302
|
+
function gt(t) {
|
|
2303
2303
|
return ot[t] || ot[t.toLowerCase()] || ot[t.toUpperCase()] || ot[t.toUpperCase().replace(/-/g, "_")] || ot[t.toLowerCase().replace(/-/g, "_")];
|
|
2304
2304
|
}
|
|
2305
2305
|
function Na(t, a = "") {
|
|
2306
2306
|
return `${a}/provider-icons/${t.toLowerCase()}.svg`;
|
|
2307
2307
|
}
|
|
2308
2308
|
function Dt(t, a = "") {
|
|
2309
|
-
const n =
|
|
2309
|
+
const n = gt(t);
|
|
2310
2310
|
return n ? `${a}/crypto-icons/${n.icon}.svg` : `${a}/crypto-icons/${t.toLowerCase()}.svg`;
|
|
2311
2311
|
}
|
|
2312
2312
|
const ca = [
|
|
@@ -2404,7 +2404,7 @@ function Bn({ className: t = "", stablecoinParity: a, partnerName: n }) {
|
|
|
2404
2404
|
fetchQuotes: u,
|
|
2405
2405
|
createOrder: s,
|
|
2406
2406
|
orderLoading: h
|
|
2407
|
-
} = Xe(), m = O(), f = l.flowType === "sell", [g, k] = w(null), A = r == null ? void 0 : r.gateways.find((te) => te.id === d), y = (q = c == null ? void 0 : c.bestQuote) != null && q.exchangeRate ? parseFloat(c.bestQuote.exchangeRate) : null, N = parseFloat(l.fiatAmount) || 0, K = !!(a && n && !f && Ea(l.cryptoCurrency) && y), z = K && l.cryptoCurrency.toUpperCase().includes(l.fiatCurrency.toUpperCase()), J = K && N > 0 ? Bt(z ? N : N / y) : null,
|
|
2407
|
+
} = Xe(), m = O(), f = l.flowType === "sell", [g, k] = w(null), A = r == null ? void 0 : r.gateways.find((te) => te.id === d), y = (q = c == null ? void 0 : c.bestQuote) != null && q.exchangeRate ? parseFloat(c.bestQuote.exchangeRate) : null, N = parseFloat(l.fiatAmount) || 0, K = !!(a && n && !f && Ea(l.cryptoCurrency) && y), z = K && l.cryptoCurrency.toUpperCase().includes(l.fiatCurrency.toUpperCase()), J = K && N > 0 ? Bt(z ? N : N / y) : null, oe = async () => {
|
|
2408
2408
|
k(null);
|
|
2409
2409
|
try {
|
|
2410
2410
|
u(), await s();
|
|
@@ -2451,7 +2451,7 @@ function Bn({ className: t = "", stablecoinParity: a, partnerName: n }) {
|
|
|
2451
2451
|
className: "w-full font-semibold text-[16px] transition-all flex items-center justify-center gap-2",
|
|
2452
2452
|
style: { height: 60, borderRadius: "var(--t-cta-radius, 100px)", background: "var(--t-cta-bg)", color: "var(--t-cta-text)", opacity: h ? 0.7 : 1 },
|
|
2453
2453
|
disabled: h,
|
|
2454
|
-
onClick:
|
|
2454
|
+
onClick: oe,
|
|
2455
2455
|
children: h ? /* @__PURE__ */ i(G, { children: [
|
|
2456
2456
|
/* @__PURE__ */ e(Ee, { size: 18 }),
|
|
2457
2457
|
m("confirm.processing")
|
|
@@ -3268,10 +3268,10 @@ function tr({ onClose: t, onSelect: a, cryptos: n, assetBaseUrl: r = "", selecte
|
|
|
3268
3268
|
}
|
|
3269
3269
|
const g = f.split(/\s+/), k = [];
|
|
3270
3270
|
for (const y of s) {
|
|
3271
|
-
const N =
|
|
3271
|
+
const N = gt(y.chain), K = N ? N.name.toLowerCase() : "", z = ((A = N == null ? void 0 : N.shortName) == null ? void 0 : A.toLowerCase()) || "", J = y.chain.toLowerCase(), oe = y.code.toLowerCase(), q = y.name.toLowerCase(), te = [oe, q, K, z, J];
|
|
3272
3272
|
if (!g.every((L) => te.some((C) => C.includes(L)))) continue;
|
|
3273
3273
|
let ae = 0;
|
|
3274
|
-
|
|
3274
|
+
oe === f ? ae += 100 : oe.startsWith(g[0]) && (ae += 50), y.popular && (ae += 10), g.length > 1 && (K.includes(g[1]) || z.includes(g[1]) || J.includes(g[1])) && (ae += 25), k.push({ item: y, score: ae });
|
|
3275
3275
|
}
|
|
3276
3276
|
return k.sort((y, N) => N.score - y.score), k.map((y) => y.item);
|
|
3277
3277
|
}, [s, c, o, l]);
|
|
@@ -3284,7 +3284,7 @@ function tr({ onClose: t, onSelect: a, cryptos: n, assetBaseUrl: r = "", selecte
|
|
|
3284
3284
|
] }),
|
|
3285
3285
|
/* @__PURE__ */ i("div", { className: "flex-1 overflow-y-auto custom-scroll px-3", children: [
|
|
3286
3286
|
m.map((f, g) => {
|
|
3287
|
-
const k =
|
|
3287
|
+
const k = gt(f.chain), A = (k == null ? void 0 : k.name) || f.chainName || f.chain, y = h(f.code, f.chain);
|
|
3288
3288
|
return /* @__PURE__ */ i(
|
|
3289
3289
|
"button",
|
|
3290
3290
|
{
|
|
@@ -3553,7 +3553,7 @@ function lr({
|
|
|
3553
3553
|
const cr = [
|
|
3554
3554
|
{ key: "settings.privacy", href: "https://nowramp.com/privacy-policy" },
|
|
3555
3555
|
{ key: "settings.terms", href: "https://nowramp.com/terms-and-conditions" }
|
|
3556
|
-
],
|
|
3556
|
+
], ft = {
|
|
3557
3557
|
background: "var(--t-surface)",
|
|
3558
3558
|
borderRadius: "var(--t-card-radius)"
|
|
3559
3559
|
};
|
|
@@ -3583,7 +3583,7 @@ function sr({
|
|
|
3583
3583
|
{
|
|
3584
3584
|
onClick: u,
|
|
3585
3585
|
className: "w-full text-left transition-colors card-press modal-item-in",
|
|
3586
|
-
style: { ...
|
|
3586
|
+
style: { ...ft, backgroundColor: "var(--t-surface)", color: "inherit", border: "none", cursor: "pointer", padding: "12px 16px" },
|
|
3587
3587
|
children: [
|
|
3588
3588
|
/* @__PURE__ */ e("span", { className: "text-[13px] block mb-1.5", style: { color: "var(--t-text-secondary)" }, children: m("settings.location") }),
|
|
3589
3589
|
/* @__PURE__ */ i("div", { className: "flex items-center justify-between", children: [
|
|
@@ -3610,7 +3610,7 @@ function sr({
|
|
|
3610
3610
|
"div",
|
|
3611
3611
|
{
|
|
3612
3612
|
className: "flex items-center justify-between w-full px-4 modal-item-in",
|
|
3613
|
-
style: { ...
|
|
3613
|
+
style: { ...ft, paddingTop: 14, paddingBottom: 14, animationDelay: "60ms" },
|
|
3614
3614
|
children: [
|
|
3615
3615
|
/* @__PURE__ */ e("span", { className: "font-medium text-[15px]", style: { color: "var(--t-text)" }, children: m("settings.darkMode") }),
|
|
3616
3616
|
/* @__PURE__ */ e(lr, { checked: a, onChange: n })
|
|
@@ -3622,7 +3622,7 @@ function sr({
|
|
|
3622
3622
|
{
|
|
3623
3623
|
onClick: s,
|
|
3624
3624
|
className: "flex items-center justify-between w-full transition-colors card-press modal-item-in",
|
|
3625
|
-
style: { ...
|
|
3625
|
+
style: { ...ft, backgroundColor: "var(--t-surface)", color: "inherit", border: "none", cursor: "pointer", padding: "14px 16px", margin: 0, textAlign: "left", animationDelay: "120ms" },
|
|
3626
3626
|
children: [
|
|
3627
3627
|
/* @__PURE__ */ e("span", { className: "font-medium text-[15px]", style: { color: "var(--t-text)" }, children: m("settings.language") }),
|
|
3628
3628
|
/* @__PURE__ */ e("span", { className: "text-[13px]", style: { color: "var(--t-text-secondary)" }, children: ((y = g.find((N) => N.code === f)) == null ? void 0 : y.name) || f })
|
|
@@ -3636,7 +3636,7 @@ function sr({
|
|
|
3636
3636
|
target: "_blank",
|
|
3637
3637
|
rel: "noopener noreferrer",
|
|
3638
3638
|
className: "flex items-center justify-between w-full px-4 transition-colors card-press modal-item-in",
|
|
3639
|
-
style: { ...
|
|
3639
|
+
style: { ...ft, textDecoration: "none", color: "inherit", paddingTop: 14, paddingBottom: 14, animationDelay: `${180 + K * 60}ms` },
|
|
3640
3640
|
children: [
|
|
3641
3641
|
/* @__PURE__ */ e("span", { className: "font-medium text-[15px]", style: { color: "var(--t-text)" }, children: m(N.key) }),
|
|
3642
3642
|
/* @__PURE__ */ e(jn, {})
|
|
@@ -3667,13 +3667,13 @@ function ur({
|
|
|
3667
3667
|
if (r) {
|
|
3668
3668
|
const s = r.toLowerCase(), h = Ot[s];
|
|
3669
3669
|
if (h) {
|
|
3670
|
-
const m =
|
|
3670
|
+
const m = yt.filter((f) => f.code !== s);
|
|
3671
3671
|
return [h, ...m];
|
|
3672
3672
|
}
|
|
3673
3673
|
}
|
|
3674
|
-
return
|
|
3674
|
+
return yt;
|
|
3675
3675
|
}
|
|
3676
|
-
return
|
|
3676
|
+
return yt.filter(
|
|
3677
3677
|
(s) => s.name.toLowerCase().includes(u) || s.code.includes(u) || s.defaultFiat.toLowerCase().includes(u)
|
|
3678
3678
|
);
|
|
3679
3679
|
}, [l, r]);
|
|
@@ -4653,7 +4653,7 @@ function Fr({
|
|
|
4653
4653
|
explorerUrl: K,
|
|
4654
4654
|
doneButtonText: z,
|
|
4655
4655
|
supportEmail: J,
|
|
4656
|
-
stablecoinParity:
|
|
4656
|
+
stablecoinParity: oe,
|
|
4657
4657
|
partnerName: q,
|
|
4658
4658
|
containerHeight: te,
|
|
4659
4659
|
locale: be,
|
|
@@ -4666,42 +4666,42 @@ function Fr({
|
|
|
4666
4666
|
config: p,
|
|
4667
4667
|
configLoading: D,
|
|
4668
4668
|
quotes: E,
|
|
4669
|
-
quotesLoading:
|
|
4669
|
+
quotesLoading: S,
|
|
4670
4670
|
quotesError: ne,
|
|
4671
4671
|
fetchQuotes: pe,
|
|
4672
4672
|
createOrder: Se,
|
|
4673
4673
|
orderLoading: Te,
|
|
4674
4674
|
amountError: he,
|
|
4675
|
-
fieldLocks:
|
|
4676
|
-
apiConfig:
|
|
4675
|
+
fieldLocks: ie,
|
|
4676
|
+
apiConfig: le,
|
|
4677
4677
|
assetBaseUrl: X,
|
|
4678
4678
|
availableFiats: fe,
|
|
4679
4679
|
availableCryptos: Qe,
|
|
4680
|
-
availablePaymentMethods:
|
|
4680
|
+
availablePaymentMethods: ce,
|
|
4681
4681
|
selectionUnsupported: ye,
|
|
4682
4682
|
quotesEmpty: $,
|
|
4683
4683
|
bestUnavailableReason: Ke
|
|
4684
|
-
} = Xe(), { locale: ze, setLocale:
|
|
4684
|
+
} = Xe(), { locale: ze, setLocale: Ct } = _t(), [se, _e] = w(a === "dark"), [Le, bt] = w(n), [de, V] = w(null), [lt, Z] = w(!1), [St, Je] = w(!1), [Fe, ct] = w(!1), [je, qe] = w(!1), [et, Ue] = w(null), [tt, wt] = w(!0), [kt, st] = w(!1), [v, R] = w(!1), [T, B] = w(!1), [M, _] = w(null), [ue, ge] = w(!1), [La, Nt] = w(30), [Fa, Gt] = w(!1), [Ua, $t] = w(!1), Ia = I(null), Et = I(), At = I(C.flowType), Ma = te ?? 640, Zt = I(E);
|
|
4685
4685
|
U(() => {
|
|
4686
4686
|
E && E !== Zt.current && B(!1), Zt.current = E;
|
|
4687
4687
|
}, [E]), U(() => {
|
|
4688
|
-
|
|
4689
|
-
}, [
|
|
4688
|
+
S && !T && F({ type: "CLEAR_QUOTE" });
|
|
4689
|
+
}, [S, T, F]), U(() => {
|
|
4690
4690
|
T || v || E != null && E.bestQuote && F({ type: "SELECT_QUOTE", quote: E.bestQuote });
|
|
4691
4691
|
}, [E == null ? void 0 : E.bestQuote, T, v, F]), U(() => {
|
|
4692
4692
|
_e(a === "dark");
|
|
4693
4693
|
}, [a]), U(() => {
|
|
4694
|
-
const x = setTimeout(() =>
|
|
4694
|
+
const x = setTimeout(() => wt(!1), D ? 0 : 800);
|
|
4695
4695
|
return () => clearTimeout(x);
|
|
4696
4696
|
}, [D]), U(() => {
|
|
4697
|
-
if (
|
|
4698
|
-
|
|
4697
|
+
if (At.current !== C.flowType && !tt) {
|
|
4698
|
+
At.current = C.flowType, st(!0), Z(!1), Je(!1);
|
|
4699
4699
|
const x = setTimeout(() => st(!1), 350);
|
|
4700
4700
|
return () => clearTimeout(x);
|
|
4701
4701
|
}
|
|
4702
|
-
|
|
4702
|
+
At.current = C.flowType;
|
|
4703
4703
|
}, [C.flowType, tt]);
|
|
4704
|
-
const dt = C.flowType, H = dt === "buy", re = C.cryptoCurrency || "BTC", xe = C.fiatCurrency || "USD",
|
|
4704
|
+
const dt = C.flowType, H = dt === "buy", re = C.cryptoCurrency || "BTC", xe = C.fiatCurrency || "USD", Rt = H ? C.fiatAmount : C.cryptoAmount, ee = Mn(Rt), ve = C.selectedQuote || (E == null ? void 0 : E.bestQuote) || null, we = ve != null && ve.exchangeRate ? parseFloat(ve.exchangeRate) : null, at = I(null);
|
|
4705
4705
|
we && re && xe && (at.current = { rate: we, crypto: re, fiat: xe }), U(() => {
|
|
4706
4706
|
($ || ne) && (at.current = null);
|
|
4707
4707
|
}, [$, ne]), U(() => {
|
|
@@ -4713,35 +4713,35 @@ function Fr({
|
|
|
4713
4713
|
if (x) return x;
|
|
4714
4714
|
}
|
|
4715
4715
|
return "0";
|
|
4716
|
-
}, [ve, H]),
|
|
4716
|
+
}, [ve, H]), Tt = I(Ie);
|
|
4717
4717
|
U(() => {
|
|
4718
|
-
if (Ie !==
|
|
4718
|
+
if (Ie !== Tt.current && Ie !== "0" && Tt.current !== "0") {
|
|
4719
4719
|
Gt(!0);
|
|
4720
4720
|
const x = setTimeout(() => Gt(!1), 500);
|
|
4721
4721
|
return () => clearTimeout(x);
|
|
4722
4722
|
}
|
|
4723
|
-
|
|
4723
|
+
Tt.current = Ie;
|
|
4724
4724
|
}, [Ie]);
|
|
4725
|
-
const nt = !!(
|
|
4725
|
+
const nt = !!(oe && q && H && Ea(re) && we), Da = nt && re.toUpperCase().includes(xe.toUpperCase()), Xt = nt && ee > 0 ? Bt(Da ? ee : ee / we) : null, Ba = nt && Xt ? Xt : Ie, Ha = j(() => {
|
|
4726
4726
|
var Y, De, Ge;
|
|
4727
|
-
const x = we || ((Y = at.current) == null ? void 0 : Y.rate),
|
|
4728
|
-
return !x || !
|
|
4727
|
+
const x = we || ((Y = at.current) == null ? void 0 : Y.rate), b = we ? re : (De = at.current) == null ? void 0 : De.crypto, W = we ? xe : (Ge = at.current) == null ? void 0 : Ge.fiat;
|
|
4728
|
+
return !x || !b || !W ? "" : `1 ${b} ≈ ${x.toFixed(2)} ${W}`;
|
|
4729
4729
|
}, [re, xe, we]);
|
|
4730
4730
|
U(() => {
|
|
4731
|
-
const x = C.walletAddress.trim(),
|
|
4731
|
+
const x = C.walletAddress.trim(), b = C.network;
|
|
4732
4732
|
if (!x || x.length < 10) {
|
|
4733
4733
|
Ue(null), F({ type: "SET_WALLET_ERROR", message: "" });
|
|
4734
4734
|
return;
|
|
4735
4735
|
}
|
|
4736
4736
|
qe(!0), Ue(null);
|
|
4737
4737
|
const W = new AbortController();
|
|
4738
|
-
return clearTimeout(
|
|
4738
|
+
return clearTimeout(Et.current), Et.current = setTimeout(async () => {
|
|
4739
4739
|
var Y, De, Ge;
|
|
4740
4740
|
try {
|
|
4741
|
-
const Ut = await (await fetch(`${
|
|
4741
|
+
const Ut = await (await fetch(`${le.apiUrl}/public/validate/address`, {
|
|
4742
4742
|
method: "POST",
|
|
4743
4743
|
headers: { "Content-Type": "application/json" },
|
|
4744
|
-
body: JSON.stringify({ address: x, ...
|
|
4744
|
+
body: JSON.stringify({ address: x, ...b ? { network: b } : {} }),
|
|
4745
4745
|
signal: W.signal
|
|
4746
4746
|
})).json(), It = ((Y = Ut.data) == null ? void 0 : Y.attributes) || Ut.data || Ut;
|
|
4747
4747
|
if (It.isValid)
|
|
@@ -4758,23 +4758,23 @@ function Fr({
|
|
|
4758
4758
|
W.signal.aborted || qe(!1);
|
|
4759
4759
|
}
|
|
4760
4760
|
}, 500), () => {
|
|
4761
|
-
clearTimeout(
|
|
4761
|
+
clearTimeout(Et.current), W.abort();
|
|
4762
4762
|
};
|
|
4763
|
-
}, [C.walletAddress, C.network,
|
|
4764
|
-
const ut = !
|
|
4765
|
-
let
|
|
4766
|
-
const W = H ? 2 : 6, Y =
|
|
4767
|
-
Y !== -1 &&
|
|
4763
|
+
}, [C.walletAddress, C.network, le.apiUrl]);
|
|
4764
|
+
const ut = !Rt || ee === 0, Lt = ee > 0 && (H ? ee < ua : ee < ma), Pa = !!he || Lt || lt && ut, Oa = ee > 0 && !he && !Lt, Yt = C.walletAddress.trim().length >= 10 && et !== !1 && !je, Qt = Oa && (H ? Yt : !0) && !!C.cryptoCurrency && !!C.network, Ka = (x) => {
|
|
4765
|
+
let b = x.target.value.replace(/[^0-9.,]/g, "");
|
|
4766
|
+
const W = H ? 2 : 6, Y = b.indexOf(".");
|
|
4767
|
+
Y !== -1 && b.length - Y - 1 > W && (b = b.slice(0, Y + W + 1)), F(H ? { type: "SET_FIAT_AMOUNT", amount: b } : { type: "SET_CRYPTO_AMOUNT", amount: b });
|
|
4768
4768
|
}, _a = (x) => {
|
|
4769
|
-
x !== dt && F({ type: "SET_FLOW_TYPE", flowType: x, fieldLocks:
|
|
4769
|
+
x !== dt && F({ type: "SET_FLOW_TYPE", flowType: x, fieldLocks: ie });
|
|
4770
4770
|
}, ja = P(
|
|
4771
4771
|
(x) => {
|
|
4772
4772
|
F({ type: "SET_FIAT_CURRENCY", currency: x });
|
|
4773
4773
|
},
|
|
4774
4774
|
[F]
|
|
4775
4775
|
), Va = P(
|
|
4776
|
-
(x,
|
|
4777
|
-
F({ type: "SET_CRYPTO_CURRENCY", currency: x }), F({ type: "SET_CRYPTO_CHAIN", chain:
|
|
4776
|
+
(x, b) => {
|
|
4777
|
+
F({ type: "SET_CRYPTO_CURRENCY", currency: x }), F({ type: "SET_CRYPTO_CHAIN", chain: b });
|
|
4778
4778
|
},
|
|
4779
4779
|
[F]
|
|
4780
4780
|
), Wa = P(
|
|
@@ -4806,22 +4806,22 @@ function Fr({
|
|
|
4806
4806
|
};
|
|
4807
4807
|
U(() => {
|
|
4808
4808
|
var x;
|
|
4809
|
-
if (!(!v ||
|
|
4809
|
+
if (!(!v || S)) {
|
|
4810
4810
|
if (E != null && E.bestQuote)
|
|
4811
|
-
R(!1), F({ type: "SELECT_QUOTE", quote: E.bestQuote }), Se().catch((
|
|
4812
|
-
_({ type: "error", title: L("toast.orderFailed"), desc:
|
|
4811
|
+
R(!1), F({ type: "SELECT_QUOTE", quote: E.bestQuote }), Se().catch((b) => {
|
|
4812
|
+
_({ type: "error", title: L("toast.orderFailed"), desc: b instanceof Error ? b.message : L("toast.couldNotCreate") });
|
|
4813
4813
|
});
|
|
4814
4814
|
else if (ne) {
|
|
4815
4815
|
R(!1);
|
|
4816
|
-
const
|
|
4817
|
-
F({ type: "SET_ERROR", message:
|
|
4816
|
+
const b = ne.message || L("error.noProviders");
|
|
4817
|
+
F({ type: "SET_ERROR", message: b }), _({ type: "error", title: L("toast.quoteError"), desc: b });
|
|
4818
4818
|
} else if (E && !E.bestQuote) {
|
|
4819
4819
|
R(!1);
|
|
4820
|
-
const
|
|
4820
|
+
const b = (x = E.unavailableGateways) == null ? void 0 : x.map((Y) => Y.reason).filter(Boolean), W = b != null && b.length ? `${L("error.noProviders")}: ${b.join("; ")}` : L("error.noProviders");
|
|
4821
4821
|
F({ type: "SET_ERROR", message: W }), _({ type: "error", title: L("toast.noProviders"), desc: W });
|
|
4822
4822
|
}
|
|
4823
4823
|
}
|
|
4824
|
-
}, [v, E,
|
|
4824
|
+
}, [v, E, S, ne, F, Se]);
|
|
4825
4825
|
const zt = I(C.step);
|
|
4826
4826
|
U(() => {
|
|
4827
4827
|
const x = zt.current;
|
|
@@ -4832,16 +4832,16 @@ function Fr({
|
|
|
4832
4832
|
Ve || ge(!1);
|
|
4833
4833
|
}, [Ve]), U(() => {
|
|
4834
4834
|
if (!ue || !Ve) return;
|
|
4835
|
-
|
|
4835
|
+
Nt(30);
|
|
4836
4836
|
const x = setInterval(() => {
|
|
4837
|
-
|
|
4837
|
+
Nt((b) => b <= 1 ? (pe(), 30) : b - 1);
|
|
4838
4838
|
}, 1e3);
|
|
4839
4839
|
return () => clearInterval(x);
|
|
4840
4840
|
}, [ue, Ve, pe]), U(() => {
|
|
4841
|
-
ue && Ve && !
|
|
4842
|
-
}, [
|
|
4841
|
+
ue && Ve && !S && Nt(30);
|
|
4842
|
+
}, [S, ue, Ve]);
|
|
4843
4843
|
const Jt = se ? "theme-dark" : "theme-light", mt = sa.find((x) => x.id === Le) || sa[0], Qa = mt.accent === null, za = r ? Ce(r) : !1, qt = (x) => {
|
|
4844
|
-
const
|
|
4844
|
+
const b = x.replace("#", ""), W = parseInt(b.substring(0, 2), 16), Y = parseInt(b.substring(2, 4), 16), De = parseInt(b.substring(4, 6), 16);
|
|
4845
4845
|
return (0.299 * W + 0.587 * Y + 0.114 * De) / 255 > 0.5 ? "#000000" : "#ffffff";
|
|
4846
4846
|
}, ea = za ? { "--t-accent": r, "--t-cta-bg": r, "--t-cta-text": qt(r) } : Qa ? {
|
|
4847
4847
|
"--t-accent": se ? "#ffffff" : "#111111",
|
|
@@ -4857,7 +4857,10 @@ function Fr({
|
|
|
4857
4857
|
o && Ce(o) ? Me.backgroundColor = o : Me.backgroundColor = "var(--t-bg)", l && (l.startsWith("https://") || l.startsWith("data:image/")) && (Me.backgroundImage = `url(${l})`, Me.backgroundSize = "cover", Me.backgroundPosition = "center");
|
|
4858
4858
|
const pt = {};
|
|
4859
4859
|
d && Ce(d) && (pt.border = `1px solid ${d}`), c && (pt.borderRadius = c);
|
|
4860
|
-
const rt = C.network, We = rt ?
|
|
4860
|
+
const rt = C.network, We = rt ? gt(rt) : null, ta = (We == null ? void 0 : We.shortName) || (We == null ? void 0 : We.name) || rt, Ja = he || (lt && (Lt || ut) ? ut ? L("error.amountZero") : H ? L("error.minAmountFiat", { min: String(ua), currency: xe }) : L("error.minAmountCrypto", { min: String(ma), currency: re }) : void 0), qa = C.walletError ? C.walletError : St && !Yt && !je ? L("wallet.invalid") : void 0, ht = ce.filter((x) => {
|
|
4861
|
+
var b;
|
|
4862
|
+
return x.supportedFiats.includes(C.fiatCurrency) ? C.selectedQuote && ((b = x.providers) != null && b.length) ? x.providers.includes(C.selectedQuote.gatewayId) : !0 : !1;
|
|
4863
|
+
}), en = ht.find((x) => x.id === C.paymentMethodId) || ht[0], aa = C.step === "checkout" ? /* @__PURE__ */ e(Nn, { autoRedirect: N }) : C.step === "processing" ? /* @__PURE__ */ e(An, {}) : C.step === "complete" ? /* @__PURE__ */ e(Rn, { explorerUrl: K, doneButtonText: z, onDone: ae }) : C.step === "error" ? /* @__PURE__ */ e(Tn, { supportEmail: J, onDone: ae, doneButtonText: z }) : C.step === "confirm" ? /* @__PURE__ */ e(Bn, { stablecoinParity: nt, partnerName: q }) : null;
|
|
4861
4864
|
return aa ? /* @__PURE__ */ e(
|
|
4862
4865
|
"div",
|
|
4863
4866
|
{
|
|
@@ -4898,18 +4901,18 @@ function Fr({
|
|
|
4898
4901
|
darkMode: se
|
|
4899
4902
|
}
|
|
4900
4903
|
),
|
|
4901
|
-
tt ||
|
|
4904
|
+
tt || kt || D ? /* @__PURE__ */ e("div", { className: "pt-[88px] px-3 flex-1 flex flex-col", children: D ? /* @__PURE__ */ e(Hn, {}) : /* @__PURE__ */ e(zn, {}) }) : /* @__PURE__ */ i("div", { className: "flex-1 overflow-hidden pt-[88px] px-3 flex flex-col gap-1 tab-fade-in", children: [
|
|
4902
4905
|
/* @__PURE__ */ e(
|
|
4903
4906
|
fr,
|
|
4904
4907
|
{
|
|
4905
|
-
amount:
|
|
4908
|
+
amount: Rt,
|
|
4906
4909
|
onAmountChange: Ka,
|
|
4907
4910
|
currencyCode: H ? xe : re,
|
|
4908
4911
|
isBuy: H,
|
|
4909
4912
|
onOpenModal: () => V(H ? "fiat" : "crypto"),
|
|
4910
4913
|
assetBaseUrl: X,
|
|
4911
4914
|
error: Ja,
|
|
4912
|
-
fieldLocks:
|
|
4915
|
+
fieldLocks: ie,
|
|
4913
4916
|
onBlur: () => Z(!0),
|
|
4914
4917
|
inputRef: Ia,
|
|
4915
4918
|
chainCode: H ? void 0 : rt,
|
|
@@ -4929,11 +4932,11 @@ function Fr({
|
|
|
4929
4932
|
onOpenModal: () => V(H ? "crypto" : "fiat"),
|
|
4930
4933
|
displayRate: Ha,
|
|
4931
4934
|
assetBaseUrl: X,
|
|
4932
|
-
quotesLoading:
|
|
4935
|
+
quotesLoading: S,
|
|
4933
4936
|
onOpenRateBreakdown: () => {
|
|
4934
4937
|
ee > 0 && ge(!0);
|
|
4935
4938
|
},
|
|
4936
|
-
fieldLocks:
|
|
4939
|
+
fieldLocks: ie,
|
|
4937
4940
|
spendNumeric: ee,
|
|
4938
4941
|
getChainIconUrl: H ? Dt : void 0,
|
|
4939
4942
|
autoSelectPending: v,
|
|
@@ -4962,23 +4965,14 @@ function Fr({
|
|
|
4962
4965
|
]
|
|
4963
4966
|
}
|
|
4964
4967
|
),
|
|
4965
|
-
(
|
|
4966
|
-
Cr,
|
|
4967
|
-
{
|
|
4968
|
-
selectedQuote: C.selectedQuote,
|
|
4969
|
-
quotesLoading: b,
|
|
4970
|
-
onOpenModal: () => V("provider"),
|
|
4971
|
-
assetBaseUrl: X
|
|
4972
|
-
}
|
|
4973
|
-
),
|
|
4974
|
-
(oe.length > 0 || (p == null ? void 0 : p.paymentMethods) && p.paymentMethods.length > 0) && (Lt.length > 0 ? /* @__PURE__ */ e(
|
|
4968
|
+
(ce.length > 0 || (p == null ? void 0 : p.paymentMethods) && p.paymentMethods.length > 0) && (ht.length > 0 ? /* @__PURE__ */ e(
|
|
4975
4969
|
vr,
|
|
4976
4970
|
{
|
|
4977
4971
|
selectedMethod: en,
|
|
4978
4972
|
onOpenModal: () => V("payment"),
|
|
4979
4973
|
darkMode: se,
|
|
4980
4974
|
getMethodIcon: Wt,
|
|
4981
|
-
getMethodDisplayName: (x,
|
|
4975
|
+
getMethodDisplayName: (x, b) => Vt(x, b, L, !0)
|
|
4982
4976
|
}
|
|
4983
4977
|
) : /* @__PURE__ */ e(
|
|
4984
4978
|
"div",
|
|
@@ -4992,6 +4986,15 @@ function Fr({
|
|
|
4992
4986
|
children: /* @__PURE__ */ e("span", { className: "text-[12px]", style: { color: "var(--t-text-muted)" }, children: L("payment.noneAvailable") })
|
|
4993
4987
|
}
|
|
4994
4988
|
)),
|
|
4989
|
+
(E || S) && /* @__PURE__ */ e(
|
|
4990
|
+
Cr,
|
|
4991
|
+
{
|
|
4992
|
+
selectedQuote: C.selectedQuote,
|
|
4993
|
+
quotesLoading: S,
|
|
4994
|
+
onOpenModal: () => V("provider"),
|
|
4995
|
+
assetBaseUrl: X
|
|
4996
|
+
}
|
|
4997
|
+
),
|
|
4995
4998
|
H && /* @__PURE__ */ e(
|
|
4996
4999
|
Ar,
|
|
4997
5000
|
{
|
|
@@ -5001,7 +5004,7 @@ function Fr({
|
|
|
5001
5004
|
isBuy: H,
|
|
5002
5005
|
error: qa,
|
|
5003
5006
|
validating: je,
|
|
5004
|
-
disabled: !!((ra =
|
|
5007
|
+
disabled: !!((ra = ie == null ? void 0 : ie.destinationAddress) != null && ra.locked),
|
|
5005
5008
|
onFocus: () => ct(!0),
|
|
5006
5009
|
onBlur: () => {
|
|
5007
5010
|
ct(!1), Je(!0);
|
|
@@ -5041,17 +5044,17 @@ function Fr({
|
|
|
5041
5044
|
isOpen: ue,
|
|
5042
5045
|
onClose: () => ge(!1),
|
|
5043
5046
|
countdown: La,
|
|
5044
|
-
quotesLoading:
|
|
5047
|
+
quotesLoading: S
|
|
5045
5048
|
}
|
|
5046
5049
|
) }),
|
|
5047
5050
|
/* @__PURE__ */ e(Pe, { isOpen: de === "fiat", onClose: () => V(null), children: (x) => /* @__PURE__ */ e(
|
|
5048
5051
|
er,
|
|
5049
5052
|
{
|
|
5050
5053
|
onClose: x,
|
|
5051
|
-
onSelect: (
|
|
5052
|
-
ja(
|
|
5054
|
+
onSelect: (b) => {
|
|
5055
|
+
ja(b), x();
|
|
5053
5056
|
},
|
|
5054
|
-
currencies: fe.map((
|
|
5057
|
+
currencies: fe.map((b) => ({ code: b.code, name: b.code })),
|
|
5055
5058
|
assetBaseUrl: X,
|
|
5056
5059
|
selectedCode: C.fiatCurrency
|
|
5057
5060
|
}
|
|
@@ -5060,15 +5063,15 @@ function Fr({
|
|
|
5060
5063
|
tr,
|
|
5061
5064
|
{
|
|
5062
5065
|
onClose: x,
|
|
5063
|
-
onSelect: (
|
|
5064
|
-
Va(
|
|
5066
|
+
onSelect: (b, W) => {
|
|
5067
|
+
Va(b, W), x();
|
|
5065
5068
|
},
|
|
5066
|
-
cryptos: Qe.map((
|
|
5069
|
+
cryptos: Qe.map((b) => {
|
|
5067
5070
|
var W;
|
|
5068
5071
|
return {
|
|
5069
|
-
code:
|
|
5070
|
-
name:
|
|
5071
|
-
networks: (W =
|
|
5072
|
+
code: b.code,
|
|
5073
|
+
name: b.code,
|
|
5074
|
+
networks: (W = b.networks) == null ? void 0 : W.map((Y) => ({ code: Y.id, name: Y.name }))
|
|
5072
5075
|
};
|
|
5073
5076
|
}),
|
|
5074
5077
|
assetBaseUrl: X,
|
|
@@ -5079,10 +5082,10 @@ function Fr({
|
|
|
5079
5082
|
/* @__PURE__ */ e(Pe, { isOpen: de === "payment", onClose: () => V(null), children: (x) => /* @__PURE__ */ e(
|
|
5080
5083
|
ir,
|
|
5081
5084
|
{
|
|
5082
|
-
methods:
|
|
5085
|
+
methods: ht,
|
|
5083
5086
|
selectedId: C.paymentMethodId,
|
|
5084
|
-
onSelect: (
|
|
5085
|
-
Wa(
|
|
5087
|
+
onSelect: (b) => {
|
|
5088
|
+
Wa(b), x();
|
|
5086
5089
|
},
|
|
5087
5090
|
onClose: x
|
|
5088
5091
|
}
|
|
@@ -5091,12 +5094,12 @@ function Fr({
|
|
|
5091
5094
|
Er,
|
|
5092
5095
|
{
|
|
5093
5096
|
quotes: E,
|
|
5094
|
-
quotesLoading:
|
|
5097
|
+
quotesLoading: S,
|
|
5095
5098
|
cryptoCurrency: re,
|
|
5096
5099
|
selectedGatewayId: C.selectedProvider,
|
|
5097
5100
|
assetBaseUrl: X,
|
|
5098
|
-
onSelect: (
|
|
5099
|
-
B(!0), F({ type: "SELECT_QUOTE", quote:
|
|
5101
|
+
onSelect: (b) => {
|
|
5102
|
+
B(!0), F({ type: "SELECT_QUOTE", quote: b }), x();
|
|
5100
5103
|
},
|
|
5101
5104
|
onClose: x
|
|
5102
5105
|
}
|
|
@@ -5108,8 +5111,8 @@ function Fr({
|
|
|
5108
5111
|
darkMode: se,
|
|
5109
5112
|
onToggleDarkMode: _e,
|
|
5110
5113
|
skinId: Le,
|
|
5111
|
-
onSelectSkin: (
|
|
5112
|
-
|
|
5114
|
+
onSelectSkin: (b) => {
|
|
5115
|
+
bt(b);
|
|
5113
5116
|
},
|
|
5114
5117
|
showThemeToggle: y,
|
|
5115
5118
|
country: C.country,
|
|
@@ -5123,8 +5126,8 @@ function Fr({
|
|
|
5123
5126
|
ur,
|
|
5124
5127
|
{
|
|
5125
5128
|
onClose: x,
|
|
5126
|
-
onSelect: (
|
|
5127
|
-
Ga(
|
|
5129
|
+
onSelect: (b) => {
|
|
5130
|
+
Ga(b), x();
|
|
5128
5131
|
},
|
|
5129
5132
|
assetBaseUrl: X,
|
|
5130
5133
|
selectedCode: C.country
|
|
@@ -5134,8 +5137,8 @@ function Fr({
|
|
|
5134
5137
|
pr,
|
|
5135
5138
|
{
|
|
5136
5139
|
onClose: x,
|
|
5137
|
-
onSelect: (
|
|
5138
|
-
|
|
5140
|
+
onSelect: (b) => {
|
|
5141
|
+
Ct(b), x();
|
|
5139
5142
|
},
|
|
5140
5143
|
selectedCode: ze
|
|
5141
5144
|
}
|
|
@@ -5166,7 +5169,7 @@ function Ur({
|
|
|
5166
5169
|
onError: K,
|
|
5167
5170
|
className: z,
|
|
5168
5171
|
theme: J,
|
|
5169
|
-
skinId:
|
|
5172
|
+
skinId: oe,
|
|
5170
5173
|
accentColor: q,
|
|
5171
5174
|
bgColor: te,
|
|
5172
5175
|
bgImage: be,
|
|
@@ -5177,18 +5180,18 @@ function Ur({
|
|
|
5177
5180
|
textColor: p,
|
|
5178
5181
|
textSecondaryColor: D,
|
|
5179
5182
|
textMutedColor: E,
|
|
5180
|
-
successColor:
|
|
5183
|
+
successColor: S,
|
|
5181
5184
|
showFlowToggle: ne,
|
|
5182
5185
|
showSettings: pe,
|
|
5183
5186
|
showThemeToggle: Se,
|
|
5184
5187
|
autoRedirect: Te,
|
|
5185
5188
|
explorerUrl: he,
|
|
5186
|
-
doneButtonText:
|
|
5187
|
-
supportEmail:
|
|
5189
|
+
doneButtonText: ie,
|
|
5190
|
+
supportEmail: le,
|
|
5188
5191
|
stablecoinParity: X,
|
|
5189
5192
|
partnerName: fe,
|
|
5190
5193
|
containerHeight: Qe,
|
|
5191
|
-
locale:
|
|
5194
|
+
locale: ce,
|
|
5192
5195
|
onDone: ye
|
|
5193
5196
|
}) {
|
|
5194
5197
|
return /* @__PURE__ */ e(
|
|
@@ -5213,12 +5216,12 @@ function Ur({
|
|
|
5213
5216
|
statusPollInterval: y,
|
|
5214
5217
|
onComplete: N,
|
|
5215
5218
|
onError: K,
|
|
5216
|
-
children: /* @__PURE__ */ e(vn, { defaultLocale:
|
|
5219
|
+
children: /* @__PURE__ */ e(vn, { defaultLocale: ce || "en", children: /* @__PURE__ */ e(
|
|
5217
5220
|
Fr,
|
|
5218
5221
|
{
|
|
5219
5222
|
className: z,
|
|
5220
5223
|
theme: J,
|
|
5221
|
-
skinId:
|
|
5224
|
+
skinId: oe,
|
|
5222
5225
|
accentColor: q,
|
|
5223
5226
|
bgColor: te,
|
|
5224
5227
|
bgImage: be,
|
|
@@ -5229,14 +5232,14 @@ function Ur({
|
|
|
5229
5232
|
textColor: p,
|
|
5230
5233
|
textSecondaryColor: D,
|
|
5231
5234
|
textMutedColor: E,
|
|
5232
|
-
successColor:
|
|
5235
|
+
successColor: S,
|
|
5233
5236
|
showFlowToggle: ne,
|
|
5234
5237
|
showSettings: pe,
|
|
5235
5238
|
showThemeToggle: Se,
|
|
5236
5239
|
autoRedirect: Te,
|
|
5237
5240
|
explorerUrl: he,
|
|
5238
|
-
doneButtonText:
|
|
5239
|
-
supportEmail:
|
|
5241
|
+
doneButtonText: ie,
|
|
5242
|
+
supportEmail: le,
|
|
5240
5243
|
stablecoinParity: X,
|
|
5241
5244
|
partnerName: fe,
|
|
5242
5245
|
containerHeight: Qe,
|
|
@@ -5294,7 +5297,7 @@ export {
|
|
|
5294
5297
|
ot as BLOCKCHAINS,
|
|
5295
5298
|
Pr as BankIcon,
|
|
5296
5299
|
Jn as BottomSheet,
|
|
5297
|
-
|
|
5300
|
+
yt as COUNTRIES,
|
|
5298
5301
|
Ot as COUNTRY_MAP,
|
|
5299
5302
|
Dn as CRYPTO_CHAIN_COMBOS,
|
|
5300
5303
|
wa as CRYPTO_CURRENCIES,
|