@nice2dev/ui-money 1.2.0 → 1.2.2
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/CHANGELOG.md +142 -0
- package/dist/components/NicePaymentMethodSelector.d.ts +1 -1
- package/dist/components/NiceTaxBreakdown.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1302 -1278
- package/dist/ui-money.css +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var G = (t, e, r) =>
|
|
4
|
-
import
|
|
5
|
-
import { jsxs as
|
|
6
|
-
import { NiceIcon as
|
|
7
|
-
const
|
|
1
|
+
var tt = Object.defineProperty;
|
|
2
|
+
var rt = (t, e, r) => e in t ? tt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var G = (t, e, r) => rt(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import nt, { useState as H, useRef as at, useEffect as ct, useMemo as K, useCallback as j, forwardRef as se, useId as _e } from "react";
|
|
5
|
+
import { jsxs as _, jsx as c, Fragment as it } from "react/jsx-runtime";
|
|
6
|
+
import { useNiceTranslation as oe, NiceIcon as Pe, useControllableState as Me, NiceTutorialButton as st, resolveTutorial as ot } from "@nice2dev/ui-core";
|
|
7
|
+
const fe = [
|
|
8
8
|
// ── Majors ─────────────────────────────────────
|
|
9
9
|
{ code: "USD", numeric: 840, symbol: "$", name: "US Dollar", decimals: 2, symbolFirst: !0 },
|
|
10
10
|
{ code: "EUR", numeric: 978, symbol: "€", name: "Euro", decimals: 2, symbolFirst: !0 },
|
|
@@ -226,174 +226,174 @@ const he = [
|
|
|
226
226
|
{ code: "ETH", numeric: 0, symbol: "Ξ", name: "Ether", decimals: 8, symbolFirst: !0 },
|
|
227
227
|
{ code: "USDC", numeric: 0, symbol: "USDC", name: "USD Coin", decimals: 6 },
|
|
228
228
|
{ code: "USDT", numeric: 0, symbol: "USDT", name: "Tether", decimals: 6 }
|
|
229
|
-
],
|
|
230
|
-
function
|
|
231
|
-
return
|
|
229
|
+
], Le = new Map(fe.map((t) => [t.code, t]));
|
|
230
|
+
function re(t) {
|
|
231
|
+
return Le.get(t.toUpperCase());
|
|
232
232
|
}
|
|
233
|
-
function
|
|
234
|
-
|
|
235
|
-
const e =
|
|
236
|
-
e >= 0 ?
|
|
233
|
+
function er(t) {
|
|
234
|
+
Le.set(t.code.toUpperCase(), t);
|
|
235
|
+
const e = fe.findIndex((r) => r.code === t.code);
|
|
236
|
+
e >= 0 ? fe[e] = t : fe.push(t);
|
|
237
237
|
}
|
|
238
|
-
function
|
|
239
|
-
const r =
|
|
240
|
-
return { amount: (t < 0 ? -1 : 1) * Math.round(Math.abs(t) *
|
|
238
|
+
function ce(t, e) {
|
|
239
|
+
const r = re(e), n = (r == null ? void 0 : r.decimals) ?? 2, a = Math.pow(10, n);
|
|
240
|
+
return { amount: (t < 0 ? -1 : 1) * Math.round(Math.abs(t) * a), currency: e.toUpperCase() };
|
|
241
241
|
}
|
|
242
|
-
function
|
|
243
|
-
const e =
|
|
242
|
+
function He(t) {
|
|
243
|
+
const e = re(t.currency), r = (e == null ? void 0 : e.decimals) ?? 2;
|
|
244
244
|
return t.amount / Math.pow(10, r);
|
|
245
245
|
}
|
|
246
|
-
function
|
|
246
|
+
function lt(t, e) {
|
|
247
247
|
return t.currency.toUpperCase() === e.currency.toUpperCase();
|
|
248
248
|
}
|
|
249
|
-
function
|
|
250
|
-
if (!
|
|
249
|
+
function $e(t, e, r) {
|
|
250
|
+
if (!lt(t, e))
|
|
251
251
|
throw new Error(`Cannot ${r} different currencies: ${t.currency} vs ${e.currency}`);
|
|
252
252
|
}
|
|
253
|
-
function
|
|
254
|
-
return
|
|
253
|
+
function ye(t, e) {
|
|
254
|
+
return $e(t, e, "add"), { amount: t.amount + e.amount, currency: t.currency };
|
|
255
255
|
}
|
|
256
|
-
function
|
|
257
|
-
return
|
|
256
|
+
function dt(t, e) {
|
|
257
|
+
return $e(t, e, "subtract"), { amount: t.amount - e.amount, currency: t.currency };
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function Se(t, e) {
|
|
260
260
|
return {
|
|
261
261
|
amount: (t.amount * e < 0 ? -1 : 1) * Math.round(Math.abs(t.amount * e)),
|
|
262
262
|
currency: t.currency
|
|
263
263
|
};
|
|
264
264
|
}
|
|
265
|
-
function
|
|
266
|
-
return
|
|
265
|
+
function tr(t, e) {
|
|
266
|
+
return $e(t, e, "compare"), t.amount - e.amount;
|
|
267
267
|
}
|
|
268
|
-
function
|
|
268
|
+
function rr(t) {
|
|
269
269
|
return t.amount === 0;
|
|
270
270
|
}
|
|
271
|
-
function
|
|
271
|
+
function nr(t) {
|
|
272
272
|
return t.amount < 0;
|
|
273
273
|
}
|
|
274
|
-
function
|
|
274
|
+
function ar(t) {
|
|
275
275
|
return { amount: -t.amount, currency: t.currency };
|
|
276
276
|
}
|
|
277
|
-
function
|
|
278
|
-
const r =
|
|
277
|
+
function ie(t, e = {}) {
|
|
278
|
+
const r = re(t.currency), n = e.decimals ?? (r == null ? void 0 : r.decimals) ?? 2, a = t.amount / Math.pow(10, n);
|
|
279
279
|
try {
|
|
280
280
|
return new Intl.NumberFormat(e.locale, {
|
|
281
281
|
style: "currency",
|
|
282
282
|
currency: t.currency,
|
|
283
|
-
minimumFractionDigits:
|
|
284
|
-
maximumFractionDigits:
|
|
283
|
+
minimumFractionDigits: n,
|
|
284
|
+
maximumFractionDigits: n,
|
|
285
285
|
currencyDisplay: e.currencyDisplay ?? "symbol"
|
|
286
|
-
}).format(
|
|
286
|
+
}).format(a);
|
|
287
287
|
} catch {
|
|
288
|
-
const i = (r == null ? void 0 : r.symbol) ?? t.currency,
|
|
289
|
-
return r != null && r.symbolFirst ? `${i}${
|
|
288
|
+
const i = (r == null ? void 0 : r.symbol) ?? t.currency, d = a.toFixed(n);
|
|
289
|
+
return r != null && r.symbolFirst ? `${i}${d}` : `${d} ${i}`;
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
|
-
function
|
|
292
|
+
function ut(t, e) {
|
|
293
293
|
if (!t)
|
|
294
294
|
return null;
|
|
295
|
-
let r = t.replace(/[^\d
|
|
295
|
+
let r = t.replace(/[^\d.,-]/g, "").trim();
|
|
296
296
|
if (!r || r === "-")
|
|
297
297
|
return null;
|
|
298
|
-
const
|
|
299
|
-
|
|
300
|
-
const
|
|
298
|
+
const n = r.startsWith("-");
|
|
299
|
+
n && (r = r.slice(1));
|
|
300
|
+
const a = r.lastIndexOf("."), i = r.lastIndexOf(","), d = Math.max(a, i);
|
|
301
301
|
let s, o = "";
|
|
302
|
-
|
|
303
|
-
const l = `${s}.${o || "0"}`,
|
|
304
|
-
return Number.isFinite(
|
|
302
|
+
d === -1 ? s = r : (s = r.slice(0, d).replace(/[.,]/g, ""), o = r.slice(d + 1).replace(/[.,]/g, ""));
|
|
303
|
+
const l = `${s}.${o || "0"}`, y = parseFloat(l);
|
|
304
|
+
return Number.isFinite(y) ? ce(n ? -y : y, e) : null;
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function ke(t) {
|
|
307
307
|
const e = (t || "").replace(/\D/g, "");
|
|
308
308
|
return e ? /^4/.test(e) ? "visa" : /^(5[1-5]|2(2[2-9]|[3-6]\d|7[01]|720))/.test(e) ? "mastercard" : /^3[47]/.test(e) ? "amex" : /^(6011|65|64[4-9]|622(12[6-9]|1[3-9]\d|[2-8]\d\d|9[01]\d|92[0-5]))/.test(e) ? "discover" : /^3(0[0-5]|[68])/.test(e) ? "diners" : /^35(2[89]|[3-8])/.test(e) ? "jcb" : /^62/.test(e) ? "unionpay" : /^(50|5[6-9]|6[0-9])/.test(e) ? "maestro" : /^(2200|2201|2202|2203|2204)/.test(e) ? "mir" : /^(4011|4312|4389|4514|4576|5041|5066|5067|509|6277|6362|6363|650|6516|6550)/.test(e) ? "elo" : /^(606282|3841)/.test(e) ? "hipercard" : "unknown" : "unknown";
|
|
309
309
|
}
|
|
310
|
-
function
|
|
310
|
+
function ze(t) {
|
|
311
311
|
const e = (t || "").replace(/\D/g, "");
|
|
312
312
|
if (e.length < 12 || e.length > 19)
|
|
313
313
|
return !1;
|
|
314
|
-
let r = 0,
|
|
315
|
-
for (let
|
|
316
|
-
let i = e.charCodeAt(
|
|
317
|
-
|
|
314
|
+
let r = 0, n = !1;
|
|
315
|
+
for (let a = e.length - 1; a >= 0; a--) {
|
|
316
|
+
let i = e.charCodeAt(a) - 48;
|
|
317
|
+
n && (i *= 2, i > 9 && (i -= 9)), r += i, n = !n;
|
|
318
318
|
}
|
|
319
319
|
return r % 10 === 0;
|
|
320
320
|
}
|
|
321
|
-
function
|
|
322
|
-
const r = (t || "").replace(/\D/g, ""),
|
|
323
|
-
return
|
|
321
|
+
function mt(t, e) {
|
|
322
|
+
const r = (t || "").replace(/\D/g, ""), n = e ?? ke(r);
|
|
323
|
+
return n === "amex" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 15)].filter(Boolean).join(" ") : n === "diners" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 14)].filter(Boolean).join(" ") : (r.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
324
324
|
}
|
|
325
|
-
function
|
|
325
|
+
function cr(t, e) {
|
|
326
326
|
const r = (t || "").replace(/\D/g, "");
|
|
327
327
|
if (r.length < 4)
|
|
328
328
|
return r;
|
|
329
|
-
const
|
|
330
|
-
return i === "amex" ? [
|
|
329
|
+
const n = r.slice(-4), a = "*".repeat(r.length - 4) + n, i = e ?? ke(r);
|
|
330
|
+
return i === "amex" ? [a.slice(0, 4), a.slice(4, 10), a.slice(10, 15)].filter(Boolean).join(" ") : i === "diners" ? [a.slice(0, 4), a.slice(4, 10), a.slice(10, 14)].filter(Boolean).join(" ") : (a.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function je(t) {
|
|
333
333
|
const e = (t || "").replace(/\D/g, "");
|
|
334
334
|
if (e.length < 3)
|
|
335
335
|
return null;
|
|
336
|
-
const r = e.slice(0, 2),
|
|
337
|
-
return !Number.isFinite(
|
|
336
|
+
const r = e.slice(0, 2), n = e.length >= 4 ? e.slice(-2) : e.slice(2, 4), a = parseInt(r, 10);
|
|
337
|
+
return !Number.isFinite(a) || a < 1 || a > 12 ? null : `${r}/${n}`;
|
|
338
338
|
}
|
|
339
|
-
function
|
|
340
|
-
const r =
|
|
339
|
+
function Ye(t, e = /* @__PURE__ */ new Date()) {
|
|
340
|
+
const r = je(t);
|
|
341
341
|
if (!r)
|
|
342
342
|
return !1;
|
|
343
|
-
const [
|
|
344
|
-
return new Date(
|
|
343
|
+
const [n, a] = r.split("/"), i = parseInt(n, 10), d = 2e3 + parseInt(a, 10);
|
|
344
|
+
return new Date(d, i, 0, 23, 59, 59, 999).getTime() >= e.getTime();
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function be(t) {
|
|
347
347
|
return t === "amex" ? 4 : 3;
|
|
348
348
|
}
|
|
349
|
-
function
|
|
349
|
+
function qe(t, e = {}) {
|
|
350
350
|
var l;
|
|
351
|
-
const r = {},
|
|
352
|
-
|
|
353
|
-
const i =
|
|
351
|
+
const r = {}, n = ke(t.number), a = ze(t.number);
|
|
352
|
+
a || (r.number = "Invalid card number");
|
|
353
|
+
const i = Ye(t.expiry, e.now);
|
|
354
354
|
i || (r.expiry = "Invalid or expired");
|
|
355
|
-
const s = (t.cvc || "").replace(/\D/g, "").length ===
|
|
356
|
-
s || (r.cvc = `CVC must be ${
|
|
355
|
+
const s = (t.cvc || "").replace(/\D/g, "").length === be(n);
|
|
356
|
+
s || (r.cvc = `CVC must be ${be(n)} digits`);
|
|
357
357
|
const o = !e.requireHolder || (((l = t.holderName) == null ? void 0 : l.trim().length) ?? 0) >= 2;
|
|
358
358
|
return o || (r.holderName = "Cardholder name required"), {
|
|
359
|
-
brand:
|
|
360
|
-
numberValid:
|
|
359
|
+
brand: n,
|
|
360
|
+
numberValid: a,
|
|
361
361
|
expiryValid: i,
|
|
362
362
|
cvcValid: s,
|
|
363
363
|
holderValid: o,
|
|
364
|
-
isValid:
|
|
364
|
+
isValid: a && i && s && o,
|
|
365
365
|
errors: r
|
|
366
366
|
};
|
|
367
367
|
}
|
|
368
|
-
class
|
|
368
|
+
class ir {
|
|
369
369
|
constructor(e) {
|
|
370
370
|
G(this, "id", "static");
|
|
371
371
|
this.rates = e;
|
|
372
372
|
}
|
|
373
373
|
async getRate(e, r) {
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
376
|
-
return { base:
|
|
377
|
-
const i = this.rates.find((l) => l.base ===
|
|
374
|
+
const n = e.toUpperCase(), a = r.toUpperCase();
|
|
375
|
+
if (n === a)
|
|
376
|
+
return { base: n, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
377
|
+
const i = this.rates.find((l) => l.base === n && l.quote === a);
|
|
378
378
|
if (i)
|
|
379
379
|
return i;
|
|
380
|
-
const
|
|
381
|
-
if (
|
|
382
|
-
return { base:
|
|
383
|
-
const s = this.rates.find((l) => l.base ===
|
|
380
|
+
const d = this.rates.find((l) => l.base === a && l.quote === n);
|
|
381
|
+
if (d)
|
|
382
|
+
return { base: n, quote: a, rate: 1 / d.rate, asOf: d.asOf };
|
|
383
|
+
const s = this.rates.find((l) => l.base === n && l.quote === "USD") ?? this.rates.find((l) => l.base === "USD" && l.quote === n), o = this.rates.find((l) => l.base === "USD" && l.quote === a) ?? this.rates.find((l) => l.base === a && l.quote === "USD");
|
|
384
384
|
if (s && o) {
|
|
385
|
-
const l = s.base === "USD" ? 1 / s.rate : s.rate,
|
|
385
|
+
const l = s.base === "USD" ? 1 / s.rate : s.rate, y = o.base === "USD" ? o.rate : 1 / o.rate;
|
|
386
386
|
return {
|
|
387
|
-
base:
|
|
388
|
-
quote:
|
|
389
|
-
rate: l *
|
|
387
|
+
base: n,
|
|
388
|
+
quote: a,
|
|
389
|
+
rate: l * y,
|
|
390
390
|
asOf: (/* @__PURE__ */ new Date()).toISOString()
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
|
-
throw new Error(`No FX rate for ${
|
|
393
|
+
throw new Error(`No FX rate for ${n}/${a}`);
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
|
-
class
|
|
396
|
+
class Ce {
|
|
397
397
|
constructor(e = {}) {
|
|
398
398
|
G(this, "cache", /* @__PURE__ */ new Map());
|
|
399
399
|
G(this, "fetchImpl");
|
|
@@ -404,8 +404,8 @@ class we {
|
|
|
404
404
|
return `${this.id}:${e.toUpperCase()}/${r.toUpperCase()}`;
|
|
405
405
|
}
|
|
406
406
|
getCached(e, r) {
|
|
407
|
-
const
|
|
408
|
-
return
|
|
407
|
+
const n = this.cacheKey(e, r), a = this.cache.get(n);
|
|
408
|
+
return a && a.expires > Date.now() ? a.rate : (a && this.cache.delete(n), null);
|
|
409
409
|
}
|
|
410
410
|
setCached(e) {
|
|
411
411
|
this.cache.set(this.cacheKey(e.base, e.quote), {
|
|
@@ -414,135 +414,135 @@ class we {
|
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
class
|
|
417
|
+
class pt extends Ce {
|
|
418
418
|
constructor(r = {}) {
|
|
419
419
|
super(r);
|
|
420
420
|
G(this, "id", "frankfurter");
|
|
421
421
|
}
|
|
422
|
-
async getRate(r,
|
|
423
|
-
const
|
|
424
|
-
if (
|
|
425
|
-
return { base:
|
|
426
|
-
const
|
|
427
|
-
if (
|
|
428
|
-
return
|
|
429
|
-
const s = `https://api.frankfurter.app/latest?from=${
|
|
422
|
+
async getRate(r, n) {
|
|
423
|
+
const a = r.toUpperCase(), i = n.toUpperCase();
|
|
424
|
+
if (a === i)
|
|
425
|
+
return { base: a, quote: i, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
426
|
+
const d = this.getCached(a, i);
|
|
427
|
+
if (d)
|
|
428
|
+
return d;
|
|
429
|
+
const s = `https://api.frankfurter.app/latest?from=${a}&to=${i}`, o = await this.fetchImpl(s);
|
|
430
430
|
if (!o.ok)
|
|
431
431
|
throw new Error(`Frankfurter HTTP ${o.status}`);
|
|
432
|
-
const l = await o.json(),
|
|
433
|
-
if (
|
|
434
|
-
throw new Error(`Frankfurter: no rate for ${
|
|
435
|
-
const
|
|
436
|
-
return this.setCached(
|
|
432
|
+
const l = await o.json(), y = l.rates[i];
|
|
433
|
+
if (y == null)
|
|
434
|
+
throw new Error(`Frankfurter: no rate for ${a}/${i}`);
|
|
435
|
+
const N = { base: a, quote: i, rate: y, asOf: l.date };
|
|
436
|
+
return this.setCached(N), N;
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
class
|
|
440
|
-
constructor(r,
|
|
441
|
-
super(
|
|
439
|
+
class yt extends Ce {
|
|
440
|
+
constructor(r, n = {}) {
|
|
441
|
+
super(n);
|
|
442
442
|
G(this, "id", "openexchangerates");
|
|
443
443
|
this.appId = r;
|
|
444
444
|
}
|
|
445
|
-
async getRate(r,
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
448
|
-
return { base:
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
return
|
|
445
|
+
async getRate(r, n) {
|
|
446
|
+
const a = r.toUpperCase(), i = n.toUpperCase();
|
|
447
|
+
if (a === i)
|
|
448
|
+
return { base: a, quote: i, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
449
|
+
const d = this.getCached(a, i);
|
|
450
|
+
if (d)
|
|
451
|
+
return d;
|
|
452
452
|
const s = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, o = await this.fetchImpl(s);
|
|
453
453
|
if (!o.ok)
|
|
454
454
|
throw new Error(`OpenExchangeRates HTTP ${o.status}`);
|
|
455
|
-
const l = await o.json(),
|
|
456
|
-
if (
|
|
457
|
-
throw new Error(`OpenExchangeRates: missing rate for ${
|
|
458
|
-
const
|
|
459
|
-
base:
|
|
455
|
+
const l = await o.json(), y = l.rates[a], N = l.rates[i];
|
|
456
|
+
if (y == null || N == null)
|
|
457
|
+
throw new Error(`OpenExchangeRates: missing rate for ${a} or ${i}`);
|
|
458
|
+
const b = {
|
|
459
|
+
base: a,
|
|
460
460
|
quote: i,
|
|
461
|
-
rate:
|
|
461
|
+
rate: N / y,
|
|
462
462
|
asOf: new Date(l.timestamp * 1e3).toISOString()
|
|
463
463
|
};
|
|
464
|
-
return this.setCached(
|
|
464
|
+
return this.setCached(b), b;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
class
|
|
467
|
+
class ht extends Ce {
|
|
468
468
|
constructor(r = {}) {
|
|
469
469
|
super(r);
|
|
470
470
|
G(this, "id", "exchangerate.host");
|
|
471
471
|
}
|
|
472
|
-
async getRate(r,
|
|
473
|
-
var
|
|
474
|
-
const
|
|
475
|
-
if (
|
|
476
|
-
return { base:
|
|
477
|
-
const
|
|
478
|
-
if (
|
|
479
|
-
return
|
|
480
|
-
const s = `https://api.exchangerate.host/convert?from=${
|
|
472
|
+
async getRate(r, n) {
|
|
473
|
+
var b;
|
|
474
|
+
const a = r.toUpperCase(), i = n.toUpperCase();
|
|
475
|
+
if (a === i)
|
|
476
|
+
return { base: a, quote: i, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
477
|
+
const d = this.getCached(a, i);
|
|
478
|
+
if (d)
|
|
479
|
+
return d;
|
|
480
|
+
const s = `https://api.exchangerate.host/convert?from=${a}&to=${i}`, o = await this.fetchImpl(s);
|
|
481
481
|
if (!o.ok)
|
|
482
482
|
throw new Error(`exchangerate.host HTTP ${o.status}`);
|
|
483
|
-
const l = await o.json(),
|
|
484
|
-
return this.setCached(
|
|
483
|
+
const l = await o.json(), y = ((b = l.info) == null ? void 0 : b.rate) ?? l.result, N = { base: a, quote: i, rate: y, asOf: l.date };
|
|
484
|
+
return this.setCached(N), N;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
class
|
|
487
|
+
class bt extends Ce {
|
|
488
488
|
constructor(r = {}) {
|
|
489
489
|
super(r);
|
|
490
490
|
G(this, "id", "nbp");
|
|
491
491
|
G(this, "table");
|
|
492
492
|
this.table = r.table ?? "A";
|
|
493
493
|
}
|
|
494
|
-
async getRate(r,
|
|
495
|
-
const
|
|
496
|
-
if (
|
|
497
|
-
return { base:
|
|
498
|
-
const
|
|
499
|
-
if (
|
|
500
|
-
return
|
|
501
|
-
const s = async (
|
|
502
|
-
var
|
|
503
|
-
if (
|
|
494
|
+
async getRate(r, n) {
|
|
495
|
+
const a = r.toUpperCase(), i = n.toUpperCase();
|
|
496
|
+
if (a === i)
|
|
497
|
+
return { base: a, quote: i, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
498
|
+
const d = this.getCached(a, i);
|
|
499
|
+
if (d)
|
|
500
|
+
return d;
|
|
501
|
+
const s = async (N) => {
|
|
502
|
+
var w;
|
|
503
|
+
if (N === "PLN")
|
|
504
504
|
return { rate: 1, date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) };
|
|
505
|
-
const
|
|
506
|
-
if (!
|
|
505
|
+
const b = `https://api.nbp.pl/api/exchangerates/rates/${this.table}/${N}/?format=json`, u = await this.fetchImpl(b);
|
|
506
|
+
if (!u.ok)
|
|
507
507
|
return null;
|
|
508
|
-
const
|
|
509
|
-
return
|
|
510
|
-
}, o = await s(
|
|
508
|
+
const h = (w = (await u.json()).rates) == null ? void 0 : w[0];
|
|
509
|
+
return h ? { rate: h.mid ?? h.ask ?? 0, date: h.effectiveDate } : null;
|
|
510
|
+
}, o = await s(a), l = await s(i);
|
|
511
511
|
if (!o || !l || o.rate === 0)
|
|
512
|
-
throw new Error(`NBP: missing rate for ${
|
|
513
|
-
const
|
|
514
|
-
base:
|
|
512
|
+
throw new Error(`NBP: missing rate for ${a} or ${i}`);
|
|
513
|
+
const y = {
|
|
514
|
+
base: a,
|
|
515
515
|
quote: i,
|
|
516
516
|
rate: o.rate / l.rate,
|
|
517
517
|
asOf: o.date
|
|
518
518
|
};
|
|
519
|
-
return this.setCached(
|
|
519
|
+
return this.setCached(y), y;
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
|
-
class
|
|
522
|
+
class ft extends pt {
|
|
523
523
|
constructor() {
|
|
524
524
|
super(...arguments);
|
|
525
525
|
G(this, "id", "ecb");
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
class
|
|
528
|
+
class _t extends ht {
|
|
529
529
|
constructor() {
|
|
530
530
|
super(...arguments);
|
|
531
531
|
G(this, "id", "free-forex");
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
-
const
|
|
535
|
-
async function
|
|
536
|
-
const
|
|
537
|
-
if (t.currency.toUpperCase() ===
|
|
534
|
+
const sr = (t = {}) => new bt(t), or = (t = {}) => new ft(t), lr = (t) => new yt(t.apiKey, t), dr = (t = {}) => new _t(t);
|
|
535
|
+
async function gt(t, e, r) {
|
|
536
|
+
const n = e.toUpperCase();
|
|
537
|
+
if (t.currency.toUpperCase() === n)
|
|
538
538
|
return t;
|
|
539
|
-
const
|
|
539
|
+
const a = re(t.currency), i = re(n), d = (a == null ? void 0 : a.decimals) ?? 2, s = (i == null ? void 0 : i.decimals) ?? 2, { rate: o } = await r.getRate(t.currency, n), y = t.amount / Math.pow(10, d) * o;
|
|
540
540
|
return {
|
|
541
|
-
currency:
|
|
542
|
-
amount: Math.round(
|
|
541
|
+
currency: n,
|
|
542
|
+
amount: Math.round(y * Math.pow(10, s))
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
|
-
class
|
|
545
|
+
class vt {
|
|
546
546
|
constructor(e = {}) {
|
|
547
547
|
G(this, "id");
|
|
548
548
|
G(this, "name");
|
|
@@ -583,12 +583,12 @@ class _t {
|
|
|
583
583
|
};
|
|
584
584
|
}
|
|
585
585
|
}
|
|
586
|
-
function V(t, e, r,
|
|
587
|
-
const i = (
|
|
588
|
-
const s =
|
|
586
|
+
function V(t, e, r, n, a) {
|
|
587
|
+
const i = (d) => {
|
|
588
|
+
const s = n == null ? void 0 : n[d];
|
|
589
589
|
return s || (async () => {
|
|
590
590
|
throw new Error(
|
|
591
|
-
`[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(
|
|
591
|
+
`[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(d)}\` implementation that calls the ${e} SDK.`
|
|
592
592
|
);
|
|
593
593
|
});
|
|
594
594
|
};
|
|
@@ -596,14 +596,14 @@ function V(t, e, r, a, n) {
|
|
|
596
596
|
id: t,
|
|
597
597
|
name: e,
|
|
598
598
|
supportedCurrencies: r,
|
|
599
|
-
minimums:
|
|
599
|
+
minimums: a,
|
|
600
600
|
authorize: i("authorize"),
|
|
601
601
|
capture: i("capture"),
|
|
602
602
|
cancel: i("cancel"),
|
|
603
603
|
refund: i("refund")
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
|
-
function
|
|
606
|
+
function Nt(t) {
|
|
607
607
|
return V("stripe", "Stripe", "*", t, {
|
|
608
608
|
USD: 50,
|
|
609
609
|
EUR: 50,
|
|
@@ -618,7 +618,7 @@ function gt(t) {
|
|
|
618
618
|
PLN: 200
|
|
619
619
|
});
|
|
620
620
|
}
|
|
621
|
-
function
|
|
621
|
+
function wt(t) {
|
|
622
622
|
return V(
|
|
623
623
|
"paypal",
|
|
624
624
|
"PayPal",
|
|
@@ -649,22 +649,22 @@ function vt(t) {
|
|
|
649
649
|
t
|
|
650
650
|
);
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function kt(t) {
|
|
653
653
|
return V("adyen", "Adyen", "*", t);
|
|
654
654
|
}
|
|
655
|
-
function
|
|
655
|
+
function Ct(t) {
|
|
656
656
|
return V("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], t);
|
|
657
657
|
}
|
|
658
|
-
function
|
|
658
|
+
function Dt(t) {
|
|
659
659
|
return V("mollie", "Mollie", "*", t);
|
|
660
660
|
}
|
|
661
|
-
function
|
|
661
|
+
function Pt(t) {
|
|
662
662
|
return V("braintree", "Braintree", "*", t);
|
|
663
663
|
}
|
|
664
|
-
function
|
|
664
|
+
function Mt(t) {
|
|
665
665
|
return V("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function St(t) {
|
|
668
668
|
return V(
|
|
669
669
|
"payu",
|
|
670
670
|
"PayU",
|
|
@@ -672,20 +672,20 @@ function Mt(t) {
|
|
|
672
672
|
t
|
|
673
673
|
);
|
|
674
674
|
}
|
|
675
|
-
function
|
|
675
|
+
function It(t) {
|
|
676
676
|
return V("przelewy24", "Przelewy24", ["PLN", "EUR"], t);
|
|
677
677
|
}
|
|
678
|
-
function
|
|
678
|
+
function $t(t = {}) {
|
|
679
679
|
return V("tpay", "Tpay", ["PLN", "EUR", "USD", "GBP"], t);
|
|
680
680
|
}
|
|
681
|
-
function
|
|
681
|
+
function xt(t = {}) {
|
|
682
682
|
return V("autopay", "Autopay", ["PLN", "EUR", "USD", "GBP", "CZK"], t);
|
|
683
683
|
}
|
|
684
|
-
function
|
|
684
|
+
function Rt(t = {}) {
|
|
685
685
|
const { acquirer: e = "native", ...r } = t;
|
|
686
686
|
return V(`blik:${e}`, `BLIK (${e})`, ["PLN"], r);
|
|
687
687
|
}
|
|
688
|
-
function
|
|
688
|
+
function Ut(t) {
|
|
689
689
|
return V(
|
|
690
690
|
"klarna",
|
|
691
691
|
"Klarna",
|
|
@@ -693,7 +693,7 @@ function xt(t) {
|
|
|
693
693
|
t
|
|
694
694
|
);
|
|
695
695
|
}
|
|
696
|
-
function
|
|
696
|
+
function At(t) {
|
|
697
697
|
return V(
|
|
698
698
|
"coinbase-commerce",
|
|
699
699
|
"Coinbase Commerce",
|
|
@@ -701,31 +701,31 @@ function Rt(t) {
|
|
|
701
701
|
t
|
|
702
702
|
);
|
|
703
703
|
}
|
|
704
|
-
const
|
|
705
|
-
mock: () => new
|
|
706
|
-
stripe: () =>
|
|
707
|
-
paypal: () =>
|
|
708
|
-
adyen: () =>
|
|
709
|
-
square: () =>
|
|
710
|
-
mollie: () =>
|
|
711
|
-
braintree: () =>
|
|
712
|
-
razorpay: () =>
|
|
713
|
-
payu: () =>
|
|
714
|
-
przelewy24: () =>
|
|
715
|
-
tpay: () =>
|
|
716
|
-
autopay: () =>
|
|
717
|
-
blik: () =>
|
|
718
|
-
klarna: () =>
|
|
719
|
-
"coinbase-commerce": () =>
|
|
704
|
+
const Tt = {
|
|
705
|
+
mock: () => new vt(),
|
|
706
|
+
stripe: () => Nt(),
|
|
707
|
+
paypal: () => wt(),
|
|
708
|
+
adyen: () => kt(),
|
|
709
|
+
square: () => Ct(),
|
|
710
|
+
mollie: () => Dt(),
|
|
711
|
+
braintree: () => Pt(),
|
|
712
|
+
razorpay: () => Mt(),
|
|
713
|
+
payu: () => St(),
|
|
714
|
+
przelewy24: () => It(),
|
|
715
|
+
tpay: () => $t(),
|
|
716
|
+
autopay: () => xt(),
|
|
717
|
+
blik: () => Rt(),
|
|
718
|
+
klarna: () => Ut(),
|
|
719
|
+
"coinbase-commerce": () => At()
|
|
720
720
|
};
|
|
721
|
-
function
|
|
722
|
-
const e =
|
|
721
|
+
function Et(t) {
|
|
722
|
+
const e = Tt[t];
|
|
723
723
|
return e ? e().supportedCurrencies : "*";
|
|
724
724
|
}
|
|
725
|
-
function
|
|
725
|
+
function Ft(t) {
|
|
726
726
|
return `/api/payments/${t}/webhook`;
|
|
727
727
|
}
|
|
728
|
-
const
|
|
728
|
+
const qt = [
|
|
729
729
|
{
|
|
730
730
|
id: "stripe",
|
|
731
731
|
name: "Stripe",
|
|
@@ -936,408 +936,418 @@ const Tt = [
|
|
|
936
936
|
supportedMethods: ["wallet"],
|
|
937
937
|
hasTestMode: !0
|
|
938
938
|
}
|
|
939
|
-
],
|
|
940
|
-
|
|
941
|
-
const { currencyKey: e, ...r } = t,
|
|
939
|
+
], we = /* @__PURE__ */ Object.fromEntries(
|
|
940
|
+
qt.map((t) => {
|
|
941
|
+
const { currencyKey: e, ...r } = t, n = {
|
|
942
942
|
...r,
|
|
943
|
-
supportedCurrencies:
|
|
944
|
-
webhookPath:
|
|
943
|
+
supportedCurrencies: Et(e ?? t.id),
|
|
944
|
+
webhookPath: Ft(t.id)
|
|
945
945
|
};
|
|
946
|
-
return [t.id,
|
|
946
|
+
return [t.id, n];
|
|
947
947
|
})
|
|
948
|
-
),
|
|
949
|
-
|
|
948
|
+
), Ot = /* @__PURE__ */ Object.values(
|
|
949
|
+
we
|
|
950
950
|
);
|
|
951
|
-
function
|
|
952
|
-
return
|
|
951
|
+
function ur(t) {
|
|
952
|
+
return we[t];
|
|
953
953
|
}
|
|
954
|
-
function
|
|
955
|
-
const r =
|
|
956
|
-
() => "amount" in t ? t :
|
|
954
|
+
function mr(t, e) {
|
|
955
|
+
const r = K(
|
|
956
|
+
() => "amount" in t ? t : ce(
|
|
957
957
|
t.major,
|
|
958
958
|
t.currency
|
|
959
959
|
),
|
|
960
960
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
961
961
|
[]
|
|
962
|
-
), [
|
|
963
|
-
(
|
|
962
|
+
), [n, a] = H(r), i = j(
|
|
963
|
+
(b) => a((u) => ce(b, u.currency)),
|
|
964
964
|
[]
|
|
965
|
-
),
|
|
966
|
-
|
|
967
|
-
}, []), s = j((
|
|
968
|
-
(
|
|
965
|
+
), d = j((b) => {
|
|
966
|
+
a((u) => ({ ...u, currency: b.toUpperCase() }));
|
|
967
|
+
}, []), s = j((b) => a((u) => ye(u, b)), []), o = j(
|
|
968
|
+
(b) => a((u) => dt(u, b)),
|
|
969
969
|
[]
|
|
970
970
|
), l = j(
|
|
971
|
-
(
|
|
971
|
+
(b) => a((u) => Se(u, b)),
|
|
972
972
|
[]
|
|
973
|
-
),
|
|
974
|
-
return { money:
|
|
973
|
+
), y = K(() => ie(n, { locale: e }), [n, e]), N = K(() => He(n), [n]);
|
|
974
|
+
return { money: n, setMoney: a, setMajor: i, setCurrency: d, add: s, subtract: o, scale: l, formatted: y, major: N };
|
|
975
975
|
}
|
|
976
|
-
function
|
|
977
|
-
const [
|
|
978
|
-
return
|
|
979
|
-
if (
|
|
980
|
-
|
|
976
|
+
function Ie(t, e, r) {
|
|
977
|
+
const [n, a] = H(null), [i, d] = H(null), [s, o] = H(!1), l = at(0), y = t == null ? void 0 : t.amount, N = t == null ? void 0 : t.currency;
|
|
978
|
+
return ct(() => {
|
|
979
|
+
if (y === void 0 || N === void 0) {
|
|
980
|
+
a(null);
|
|
981
981
|
return;
|
|
982
982
|
}
|
|
983
|
-
const
|
|
984
|
-
o(!0),
|
|
985
|
-
l.current ===
|
|
986
|
-
}).catch((
|
|
987
|
-
l.current ===
|
|
983
|
+
const b = ++l.current;
|
|
984
|
+
o(!0), d(null), gt({ amount: y, currency: N }, e, r).then((u) => {
|
|
985
|
+
l.current === b && a(u);
|
|
986
|
+
}).catch((u) => {
|
|
987
|
+
l.current === b && (d(u instanceof Error ? u : new Error(String(u))), a(null));
|
|
988
988
|
}).finally(() => {
|
|
989
|
-
l.current ===
|
|
989
|
+
l.current === b && o(!1);
|
|
990
990
|
});
|
|
991
|
-
}, [
|
|
991
|
+
}, [y, N, e, r]), { converted: n, loading: s, error: i };
|
|
992
992
|
}
|
|
993
993
|
function Kt(t) {
|
|
994
|
-
const [e, r] =
|
|
995
|
-
r("idle"),
|
|
994
|
+
const [e, r] = H("idle"), [n, a] = H(null), [i, d] = H(null), s = j(() => {
|
|
995
|
+
r("idle"), a(null), d(null);
|
|
996
996
|
}, []), o = j(
|
|
997
|
-
async (
|
|
998
|
-
r("authorizing"),
|
|
997
|
+
async (b) => {
|
|
998
|
+
r("authorizing"), d(null);
|
|
999
999
|
try {
|
|
1000
|
-
const
|
|
1001
|
-
return
|
|
1002
|
-
} catch (
|
|
1003
|
-
const
|
|
1004
|
-
throw
|
|
1000
|
+
const u = await t.authorize(b);
|
|
1001
|
+
return a(u), r(u.status), u;
|
|
1002
|
+
} catch (u) {
|
|
1003
|
+
const f = u instanceof Error ? u : new Error(String(u));
|
|
1004
|
+
throw d(f), r("failed"), f;
|
|
1005
1005
|
}
|
|
1006
1006
|
},
|
|
1007
1007
|
[t]
|
|
1008
1008
|
), l = j(
|
|
1009
|
-
async (
|
|
1010
|
-
const
|
|
1011
|
-
if (!
|
|
1009
|
+
async (b, u) => {
|
|
1010
|
+
const f = b ?? (n == null ? void 0 : n.id);
|
|
1011
|
+
if (!f)
|
|
1012
1012
|
throw new Error("No authorization id to capture");
|
|
1013
1013
|
r("capturing");
|
|
1014
1014
|
try {
|
|
1015
|
-
const
|
|
1016
|
-
return
|
|
1017
|
-
} catch (
|
|
1018
|
-
const
|
|
1019
|
-
throw
|
|
1015
|
+
const h = await t.capture(f, u);
|
|
1016
|
+
return a(h), r(h.status), h;
|
|
1017
|
+
} catch (h) {
|
|
1018
|
+
const w = h instanceof Error ? h : new Error(String(h));
|
|
1019
|
+
throw d(w), r("failed"), w;
|
|
1020
1020
|
}
|
|
1021
1021
|
},
|
|
1022
|
-
[t,
|
|
1023
|
-
),
|
|
1024
|
-
async (
|
|
1025
|
-
const
|
|
1026
|
-
if (!
|
|
1022
|
+
[t, n == null ? void 0 : n.id]
|
|
1023
|
+
), y = j(
|
|
1024
|
+
async (b) => {
|
|
1025
|
+
const u = b ?? (n == null ? void 0 : n.id);
|
|
1026
|
+
if (!u)
|
|
1027
1027
|
throw new Error("No payment id to cancel");
|
|
1028
|
-
const
|
|
1029
|
-
return
|
|
1028
|
+
const f = await t.cancel(u);
|
|
1029
|
+
return a(f), r(f.status), f;
|
|
1030
1030
|
},
|
|
1031
|
-
[t,
|
|
1032
|
-
),
|
|
1033
|
-
async (
|
|
1034
|
-
const
|
|
1035
|
-
if (!
|
|
1031
|
+
[t, n == null ? void 0 : n.id]
|
|
1032
|
+
), N = j(
|
|
1033
|
+
async (b, u) => {
|
|
1034
|
+
const f = b ?? (n == null ? void 0 : n.id);
|
|
1035
|
+
if (!f)
|
|
1036
1036
|
throw new Error("No payment id to refund");
|
|
1037
|
-
const
|
|
1038
|
-
return
|
|
1037
|
+
const h = await t.refund(f, u);
|
|
1038
|
+
return a(h), r(h.status), h;
|
|
1039
1039
|
},
|
|
1040
|
-
[t,
|
|
1040
|
+
[t, n == null ? void 0 : n.id]
|
|
1041
1041
|
);
|
|
1042
|
-
return { status: e, response:
|
|
1042
|
+
return { status: e, response: n, error: i, authorize: o, capture: l, cancel: y, refund: N, reset: s };
|
|
1043
1043
|
}
|
|
1044
|
-
const
|
|
1045
|
-
value: e,
|
|
1046
|
-
amount: r,
|
|
1047
|
-
currency: a,
|
|
1048
|
-
locale: n,
|
|
1049
|
-
display: i = "symbol",
|
|
1050
|
-
highlightNegative: u = !0,
|
|
1051
|
-
zeroPlaceholder: s,
|
|
1052
|
-
convertTo: o,
|
|
1053
|
-
exchangeProvider: l,
|
|
1054
|
-
className: p,
|
|
1055
|
-
style: v,
|
|
1056
|
-
"aria-label": y
|
|
1057
|
-
}, d) {
|
|
1058
|
-
const b = q(() => {
|
|
1059
|
-
if (e)
|
|
1060
|
-
return e;
|
|
1061
|
-
if (r != null && a) {
|
|
1062
|
-
const N = te(a), D = (N == null ? void 0 : N.decimals) ?? 2;
|
|
1063
|
-
return {
|
|
1064
|
-
amount: Math.round(r * Math.pow(10, D)),
|
|
1065
|
-
currency: a.toUpperCase()
|
|
1066
|
-
};
|
|
1067
|
-
}
|
|
1068
|
-
return null;
|
|
1069
|
-
}, [e, r, a]), f = q(() => b ? b.amount === 0 && s != null ? s : ce(b, { locale: n, currencyDisplay: i }) : "", [b, n, i, s]), { converted: g } = Pe(
|
|
1070
|
-
o && l ? b : null,
|
|
1071
|
-
o ?? "",
|
|
1072
|
-
l
|
|
1073
|
-
);
|
|
1074
|
-
if (!b)
|
|
1075
|
-
return null;
|
|
1076
|
-
const _ = b.amount < 0, w = "nice-money" + (u && _ ? " nice-money--negative" : "") + (p ? ` ${p}` : "");
|
|
1077
|
-
return /* @__PURE__ */ h("span", { ref: d, className: w, style: v, "aria-label": y, children: [
|
|
1078
|
-
/* @__PURE__ */ c("span", { className: "nice-money__value", children: f }),
|
|
1079
|
-
g && /* @__PURE__ */ h("span", { className: "nice-money__converted", "aria-label": `Converted to ${g.currency}`, children: [
|
|
1080
|
-
" ≈ ",
|
|
1081
|
-
ce(g, { locale: n })
|
|
1082
|
-
] })
|
|
1083
|
-
] });
|
|
1084
|
-
}), lr = he.map((t) => t.code).sort(), je = ie(
|
|
1044
|
+
const Oe = /* @__PURE__ */ se(
|
|
1085
1045
|
function({
|
|
1086
1046
|
value: e,
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
);
|
|
1122
|
-
}, [a, Z]), m = q(() => {
|
|
1123
|
-
const P = /* @__PURE__ */ new Set();
|
|
1124
|
-
return n.map((S) => te(S)).filter((S) => !!S && !P.has(S.code) && !!P.add(S.code));
|
|
1125
|
-
}, [n]), L = j(
|
|
1126
|
-
(P) => {
|
|
1127
|
-
const S = P.target.value, oe = te(S);
|
|
1128
|
-
oe && (r == null || r(S, oe));
|
|
1129
|
-
},
|
|
1130
|
-
[r]
|
|
1131
|
-
), H = (P) => {
|
|
1132
|
-
if (o)
|
|
1133
|
-
return `${s ? P.symbol + " " : ""}${P.code}`;
|
|
1134
|
-
const S = [];
|
|
1135
|
-
return s && S.push(P.symbol), u && S.push(P.code), S.push("—", P.name), S.join(" ");
|
|
1136
|
-
}, C = `nice-currency-selector nice-currency-selector--${_} nice-currency-selector--label-${w}` + (o ? " nice-currency-selector--compact" : "") + (f ? " nice-currency-selector--error" : "") + (Q ? " nice-currency-selector--disabled" : "") + (x ? ` ${x}` : ""), K = w === "left" && N != null ? { width: typeof N == "number" ? `${N}px` : N, flex: "none" } : void 0, se = D != null ? {
|
|
1137
|
-
width: typeof D == "number" ? `${D}px` : D,
|
|
1138
|
-
flex: "none"
|
|
1139
|
-
} : void 0;
|
|
1140
|
-
return T ? null : /* @__PURE__ */ h("div", { ref: F, className: C, style: A, title: R, "data-testid": X, children: [
|
|
1141
|
-
d && /* @__PURE__ */ h("label", { htmlFor: ae, className: "nice-currency-selector__label", style: K, children: [
|
|
1142
|
-
d,
|
|
1143
|
-
g && /* @__PURE__ */ c("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
|
|
1144
|
-
] }),
|
|
1145
|
-
/* @__PURE__ */ h("div", { className: "nice-currency-selector__inner", style: se, children: [
|
|
1146
|
-
E && /* @__PURE__ */ c(
|
|
1147
|
-
"input",
|
|
1148
|
-
{
|
|
1149
|
-
type: "search",
|
|
1150
|
-
className: "nice-currency-selector__search",
|
|
1151
|
-
placeholder: "Search currency…",
|
|
1152
|
-
value: Z,
|
|
1153
|
-
onChange: (P) => U(P.target.value),
|
|
1154
|
-
disabled: Q || ne,
|
|
1155
|
-
"aria-label": "Search currency"
|
|
1156
|
-
}
|
|
1157
|
-
),
|
|
1158
|
-
/* @__PURE__ */ h(
|
|
1159
|
-
"select",
|
|
1160
|
-
{
|
|
1161
|
-
id: ae,
|
|
1162
|
-
name: M,
|
|
1163
|
-
className: "nice-currency-selector__select",
|
|
1164
|
-
value: e ?? "",
|
|
1165
|
-
onChange: L,
|
|
1166
|
-
disabled: Q || ne,
|
|
1167
|
-
required: g,
|
|
1168
|
-
"aria-invalid": !!f,
|
|
1169
|
-
"aria-label": O ?? (typeof d == "string" ? d : "Currency"),
|
|
1170
|
-
children: [
|
|
1171
|
-
!e && /* @__PURE__ */ c("option", { value: "", children: k ?? "Select currency…" }),
|
|
1172
|
-
m.length > 0 && /* @__PURE__ */ c("optgroup", { label: "Recent", children: m.map((P) => /* @__PURE__ */ c("option", { value: P.code, children: H(P) }, `r-${P.code}`)) }),
|
|
1173
|
-
/* @__PURE__ */ c("optgroup", { label: m.length > 0 ? "All" : "", children: Y.map((P) => /* @__PURE__ */ c("option", { value: P.code, children: H(P) }, P.code)) })
|
|
1174
|
-
]
|
|
1175
|
-
}
|
|
1176
|
-
)
|
|
1177
|
-
] }),
|
|
1178
|
-
(f || b) && /* @__PURE__ */ c(
|
|
1047
|
+
amount: r,
|
|
1048
|
+
currency: n,
|
|
1049
|
+
locale: a,
|
|
1050
|
+
display: i = "symbol",
|
|
1051
|
+
highlightNegative: d = !0,
|
|
1052
|
+
zeroPlaceholder: s,
|
|
1053
|
+
convertTo: o,
|
|
1054
|
+
exchangeProvider: l,
|
|
1055
|
+
className: y,
|
|
1056
|
+
style: N,
|
|
1057
|
+
"aria-label": b
|
|
1058
|
+
}, u) {
|
|
1059
|
+
const { t: f } = oe(), h = K(() => {
|
|
1060
|
+
if (e)
|
|
1061
|
+
return e;
|
|
1062
|
+
if (r != null && n) {
|
|
1063
|
+
const v = re(n), S = (v == null ? void 0 : v.decimals) ?? 2;
|
|
1064
|
+
return {
|
|
1065
|
+
amount: Math.round(r * Math.pow(10, S)),
|
|
1066
|
+
currency: n.toUpperCase()
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
return null;
|
|
1070
|
+
}, [e, r, n]), w = K(() => h ? h.amount === 0 && s != null ? s : ie(h, { locale: a, currencyDisplay: i }) : "", [h, a, i, s]), { converted: x } = Ie(
|
|
1071
|
+
o && l ? h : null,
|
|
1072
|
+
o ?? "",
|
|
1073
|
+
l
|
|
1074
|
+
);
|
|
1075
|
+
if (!h)
|
|
1076
|
+
return null;
|
|
1077
|
+
const m = h.amount < 0, g = "nice-money" + (d && m ? " nice-money--negative" : "") + (y ? ` ${y}` : "");
|
|
1078
|
+
return /* @__PURE__ */ _("span", { ref: u, className: g, style: N, "aria-label": b, children: [
|
|
1079
|
+
/* @__PURE__ */ c("span", { className: "nice-money__value", children: w }),
|
|
1080
|
+
x && /* @__PURE__ */ _(
|
|
1179
1081
|
"span",
|
|
1180
1082
|
{
|
|
1181
|
-
className:
|
|
1182
|
-
|
|
1083
|
+
className: "nice-money__converted",
|
|
1084
|
+
"aria-label": f("money.convertedTo", "Converted to {currency}").replace(
|
|
1085
|
+
"{currency}",
|
|
1086
|
+
String(x.currency)
|
|
1087
|
+
),
|
|
1088
|
+
children: [
|
|
1089
|
+
" ≈ ",
|
|
1090
|
+
ie(x, { locale: a })
|
|
1091
|
+
]
|
|
1183
1092
|
}
|
|
1184
1093
|
)
|
|
1185
1094
|
] });
|
|
1186
1095
|
}
|
|
1187
|
-
),
|
|
1096
|
+
), pr = fe.map((t) => t.code).sort(), Ge = /* @__PURE__ */ se(function({
|
|
1097
|
+
value: e,
|
|
1098
|
+
onChange: r,
|
|
1099
|
+
options: n = fe,
|
|
1100
|
+
recents: a = [],
|
|
1101
|
+
searchable: i,
|
|
1102
|
+
showCode: d = !0,
|
|
1103
|
+
showSymbol: s = !0,
|
|
1104
|
+
compact: o = !1,
|
|
1105
|
+
disabled: l,
|
|
1106
|
+
readOnly: y,
|
|
1107
|
+
loading: N,
|
|
1108
|
+
accessMode: b,
|
|
1109
|
+
label: u,
|
|
1110
|
+
helperText: f,
|
|
1111
|
+
error: h,
|
|
1112
|
+
required: w,
|
|
1113
|
+
size: x = "md",
|
|
1114
|
+
labelPlacement: m = "top",
|
|
1115
|
+
labelWidth: g,
|
|
1116
|
+
controlWidth: v,
|
|
1117
|
+
className: S,
|
|
1118
|
+
style: A,
|
|
1119
|
+
id: P,
|
|
1120
|
+
name: M,
|
|
1121
|
+
title: q,
|
|
1122
|
+
"data-testid": I,
|
|
1123
|
+
"aria-label": W,
|
|
1124
|
+
placeholder: B
|
|
1125
|
+
}, D) {
|
|
1126
|
+
const { t: T } = oe(), O = b === "hidden", X = l || b === "disabled" || N, ne = y || b === "readOnly", Y = _e(), Z = P ?? `nice-cs-${Y}`, [Q, ae] = H(""), E = i ?? n.length > 8, k = K(() => {
|
|
1127
|
+
if (!Q.trim())
|
|
1128
|
+
return n;
|
|
1129
|
+
const $ = Q.trim().toLowerCase();
|
|
1130
|
+
return n.filter(
|
|
1131
|
+
(R) => R.code.toLowerCase().includes($) || R.name.toLowerCase().includes($) || R.symbol.toLowerCase().includes($)
|
|
1132
|
+
);
|
|
1133
|
+
}, [n, Q]), p = K(() => {
|
|
1134
|
+
const $ = /* @__PURE__ */ new Set();
|
|
1135
|
+
return a.map((R) => re(R)).filter((R) => !!R && !$.has(R.code) && !!$.add(R.code));
|
|
1136
|
+
}, [a]), F = j(
|
|
1137
|
+
($) => {
|
|
1138
|
+
const R = $.target.value, de = re(R);
|
|
1139
|
+
de && (r == null || r(R, de));
|
|
1140
|
+
},
|
|
1141
|
+
[r]
|
|
1142
|
+
), z = ($) => {
|
|
1143
|
+
if (o)
|
|
1144
|
+
return `${s ? $.symbol + " " : ""}${$.code}`;
|
|
1145
|
+
const R = [];
|
|
1146
|
+
return s && R.push($.symbol), d && R.push($.code), R.push("—", $.name), R.join(" ");
|
|
1147
|
+
}, C = `nice-currency-selector nice-currency-selector--${x} nice-currency-selector--label-${m}` + (o ? " nice-currency-selector--compact" : "") + (h ? " nice-currency-selector--error" : "") + (X ? " nice-currency-selector--disabled" : "") + (S ? ` ${S}` : ""), L = m === "left" && g != null ? { width: typeof g == "number" ? `${g}px` : g, flex: "none" } : void 0, le = v != null ? {
|
|
1148
|
+
width: typeof v == "number" ? `${v}px` : v,
|
|
1149
|
+
flex: "none"
|
|
1150
|
+
} : void 0;
|
|
1151
|
+
return O ? null : /* @__PURE__ */ _("div", { ref: D, className: C, style: A, title: q, "data-testid": I, children: [
|
|
1152
|
+
u && /* @__PURE__ */ _("label", { htmlFor: Z, className: "nice-currency-selector__label", style: L, children: [
|
|
1153
|
+
u,
|
|
1154
|
+
w && /* @__PURE__ */ c("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
|
|
1155
|
+
] }),
|
|
1156
|
+
/* @__PURE__ */ _("div", { className: "nice-currency-selector__inner", style: le, children: [
|
|
1157
|
+
E && /* @__PURE__ */ c(
|
|
1158
|
+
"input",
|
|
1159
|
+
{
|
|
1160
|
+
type: "search",
|
|
1161
|
+
className: "nice-currency-selector__search",
|
|
1162
|
+
placeholder: T("currencySelector.searchCurrency", "Search currency…"),
|
|
1163
|
+
value: Q,
|
|
1164
|
+
onChange: ($) => ae($.target.value),
|
|
1165
|
+
disabled: X || ne,
|
|
1166
|
+
"aria-label": T("currencySelector.searchCurrency2", "Search currency")
|
|
1167
|
+
}
|
|
1168
|
+
),
|
|
1169
|
+
/* @__PURE__ */ _(
|
|
1170
|
+
"select",
|
|
1171
|
+
{
|
|
1172
|
+
id: Z,
|
|
1173
|
+
name: M,
|
|
1174
|
+
className: "nice-currency-selector__select",
|
|
1175
|
+
value: e ?? "",
|
|
1176
|
+
onChange: F,
|
|
1177
|
+
disabled: X || ne,
|
|
1178
|
+
required: w,
|
|
1179
|
+
"aria-invalid": !!h,
|
|
1180
|
+
"aria-label": W ?? (typeof u == "string" ? u : T("currencySelector.currency", "Currency")),
|
|
1181
|
+
children: [
|
|
1182
|
+
!e && /* @__PURE__ */ c("option", { value: "", children: B ?? T("currencySelector.selectCurrency", "Select currency…") }),
|
|
1183
|
+
p.length > 0 && /* @__PURE__ */ c("optgroup", { label: T("currencySelector.recent", "Recent"), children: p.map(($) => /* @__PURE__ */ c("option", { value: $.code, children: z($) }, `r-${$.code}`)) }),
|
|
1184
|
+
/* @__PURE__ */ c("optgroup", { label: p.length > 0 ? T("currencySelector.all", "All") : "", children: k.map(($) => /* @__PURE__ */ c("option", { value: $.code, children: z($) }, $.code)) })
|
|
1185
|
+
]
|
|
1186
|
+
}
|
|
1187
|
+
)
|
|
1188
|
+
] }),
|
|
1189
|
+
(h || f) && /* @__PURE__ */ c(
|
|
1190
|
+
"span",
|
|
1191
|
+
{
|
|
1192
|
+
className: h ? "nice-currency-selector__error" : "nice-currency-selector__helper",
|
|
1193
|
+
children: h ?? f
|
|
1194
|
+
}
|
|
1195
|
+
)
|
|
1196
|
+
] });
|
|
1197
|
+
}), Ze = /* @__PURE__ */ se(
|
|
1188
1198
|
function({
|
|
1189
1199
|
value: e,
|
|
1190
1200
|
onChange: r,
|
|
1191
|
-
currency:
|
|
1192
|
-
onCurrencyChange:
|
|
1201
|
+
currency: n,
|
|
1202
|
+
onCurrencyChange: a,
|
|
1193
1203
|
currencies: i,
|
|
1194
|
-
hideCurrencySelector:
|
|
1204
|
+
hideCurrencySelector: d,
|
|
1195
1205
|
min: s,
|
|
1196
1206
|
max: o,
|
|
1197
1207
|
step: l,
|
|
1198
|
-
locale:
|
|
1199
|
-
placeholder:
|
|
1200
|
-
label:
|
|
1201
|
-
helperText:
|
|
1202
|
-
error:
|
|
1203
|
-
size:
|
|
1204
|
-
disabled:
|
|
1205
|
-
readOnly:
|
|
1206
|
-
required:
|
|
1207
|
-
loading:
|
|
1208
|
-
accessMode:
|
|
1209
|
-
labelPlacement:
|
|
1208
|
+
locale: y,
|
|
1209
|
+
placeholder: N,
|
|
1210
|
+
label: b,
|
|
1211
|
+
helperText: u,
|
|
1212
|
+
error: f,
|
|
1213
|
+
size: h = "md",
|
|
1214
|
+
disabled: w,
|
|
1215
|
+
readOnly: x,
|
|
1216
|
+
required: m,
|
|
1217
|
+
loading: g,
|
|
1218
|
+
accessMode: v,
|
|
1219
|
+
labelPlacement: S = "top",
|
|
1210
1220
|
errorPlacement: A = "bottom",
|
|
1211
|
-
labelWidth:
|
|
1221
|
+
labelWidth: P,
|
|
1212
1222
|
controlWidth: M,
|
|
1213
|
-
submitOnEnter:
|
|
1214
|
-
onSubmit:
|
|
1215
|
-
showFormattedPreview:
|
|
1216
|
-
showSteppers:
|
|
1217
|
-
className:
|
|
1223
|
+
submitOnEnter: q,
|
|
1224
|
+
onSubmit: I,
|
|
1225
|
+
showFormattedPreview: W = !0,
|
|
1226
|
+
showSteppers: B = !1,
|
|
1227
|
+
className: D,
|
|
1218
1228
|
style: T,
|
|
1219
|
-
id:
|
|
1220
|
-
name:
|
|
1221
|
-
title:
|
|
1222
|
-
"data-testid":
|
|
1229
|
+
id: O,
|
|
1230
|
+
name: X,
|
|
1231
|
+
title: ne,
|
|
1232
|
+
"data-testid": Y,
|
|
1223
1233
|
onBlur: Z,
|
|
1224
|
-
onFocus:
|
|
1225
|
-
liveGrouping:
|
|
1226
|
-
multiplierShortcuts:
|
|
1227
|
-
onValidationError:
|
|
1228
|
-
},
|
|
1229
|
-
const
|
|
1230
|
-
() => e ? (e.amount / Math.pow(10,
|
|
1231
|
-
), [
|
|
1232
|
-
|
|
1233
|
-
if (
|
|
1234
|
+
onFocus: Q,
|
|
1235
|
+
liveGrouping: ae,
|
|
1236
|
+
multiplierShortcuts: E = !0,
|
|
1237
|
+
onValidationError: k
|
|
1238
|
+
}, p) {
|
|
1239
|
+
const { t: F } = oe(), z = w || v === "disabled" || g, C = x || v === "readOnly", L = v === "hidden", le = _e(), $ = O ?? `nice-money-${le}`, R = ((e == null ? void 0 : e.currency) ?? n ?? "USD").toUpperCase(), de = re(R), ee = (de == null ? void 0 : de.decimals) ?? 2, xe = l ?? 1 / Math.pow(10, ee), [De, ge] = H(
|
|
1240
|
+
() => e ? (e.amount / Math.pow(10, ee)).toFixed(ee) : ""
|
|
1241
|
+
), [ve, Re] = H(!1);
|
|
1242
|
+
nt.useEffect(() => {
|
|
1243
|
+
if (ve)
|
|
1234
1244
|
return;
|
|
1235
1245
|
if (e == null) {
|
|
1236
|
-
|
|
1246
|
+
ge("");
|
|
1237
1247
|
return;
|
|
1238
1248
|
}
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
}, [e,
|
|
1242
|
-
const
|
|
1243
|
-
(
|
|
1244
|
-
let J =
|
|
1245
|
-
if (
|
|
1246
|
-
const
|
|
1247
|
-
if (
|
|
1248
|
-
const
|
|
1249
|
-
if (!Number.isFinite(
|
|
1250
|
-
|
|
1249
|
+
const U = re(e.currency), J = (U == null ? void 0 : U.decimals) ?? 2;
|
|
1250
|
+
ge((e.amount / Math.pow(10, J)).toFixed(J));
|
|
1251
|
+
}, [e, ve]);
|
|
1252
|
+
const Ue = j(
|
|
1253
|
+
(U) => {
|
|
1254
|
+
let J = U;
|
|
1255
|
+
if (E) {
|
|
1256
|
+
const me = U.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);
|
|
1257
|
+
if (me) {
|
|
1258
|
+
const pe = me[2].toLowerCase() === "k" ? 1e3 : me[2].toLowerCase() === "m" ? 1e6 : 1e9, Fe = Number(me[1].replace(",", ".")) * pe;
|
|
1259
|
+
if (!Number.isFinite(Fe)) {
|
|
1260
|
+
k == null || k(new Error("overflow"));
|
|
1251
1261
|
return;
|
|
1252
1262
|
}
|
|
1253
|
-
J = String(
|
|
1263
|
+
J = String(Fe);
|
|
1254
1264
|
}
|
|
1255
1265
|
}
|
|
1256
|
-
const
|
|
1257
|
-
if (!
|
|
1266
|
+
const te = ut(J, R);
|
|
1267
|
+
if (!te) {
|
|
1258
1268
|
r == null || r(null);
|
|
1259
1269
|
return;
|
|
1260
1270
|
}
|
|
1261
|
-
if (!Number.isSafeInteger(
|
|
1262
|
-
|
|
1271
|
+
if (!Number.isSafeInteger(te.amount)) {
|
|
1272
|
+
k == null || k(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));
|
|
1263
1273
|
return;
|
|
1264
1274
|
}
|
|
1265
|
-
const
|
|
1266
|
-
if (s != null &&
|
|
1267
|
-
|
|
1275
|
+
const ue = te.amount / Math.pow(10, ee);
|
|
1276
|
+
if (s != null && ue < s) {
|
|
1277
|
+
k == null || k(new Error(`min: ${s}`)), r == null || r(ce(s, R));
|
|
1268
1278
|
return;
|
|
1269
1279
|
}
|
|
1270
|
-
if (o != null &&
|
|
1271
|
-
|
|
1280
|
+
if (o != null && ue > o) {
|
|
1281
|
+
k == null || k(new Error(`max: ${o}`)), r == null || r(ce(o, R));
|
|
1272
1282
|
return;
|
|
1273
1283
|
}
|
|
1274
|
-
r == null || r(
|
|
1284
|
+
r == null || r(te);
|
|
1275
1285
|
},
|
|
1276
|
-
[
|
|
1277
|
-
),
|
|
1278
|
-
(
|
|
1279
|
-
const J =
|
|
1280
|
-
|
|
1286
|
+
[R, ee, s, o, r, E, k]
|
|
1287
|
+
), Je = j(
|
|
1288
|
+
(U) => {
|
|
1289
|
+
const J = U.target.value;
|
|
1290
|
+
ge(J), Ue(J);
|
|
1281
1291
|
},
|
|
1282
|
-
[
|
|
1283
|
-
),
|
|
1284
|
-
(
|
|
1285
|
-
const
|
|
1286
|
-
r == null || r(
|
|
1292
|
+
[Ue]
|
|
1293
|
+
), Ae = j(
|
|
1294
|
+
(U) => {
|
|
1295
|
+
const te = (e ? e.amount / Math.pow(10, ee) : 0) + U, ue = Math.min(o ?? 1 / 0, Math.max(s ?? -1 / 0, te));
|
|
1296
|
+
r == null || r(ce(ue, R));
|
|
1287
1297
|
},
|
|
1288
|
-
[e,
|
|
1289
|
-
),
|
|
1290
|
-
var
|
|
1298
|
+
[e, ee, s, o, R, r]
|
|
1299
|
+
), Ne = K(() => {
|
|
1300
|
+
var U, J;
|
|
1291
1301
|
try {
|
|
1292
|
-
const
|
|
1293
|
-
return { group:
|
|
1302
|
+
const te = new Intl.NumberFormat(y).formatToParts(12345.6), ue = ((U = te.find((pe) => pe.type === "group")) == null ? void 0 : U.value) ?? ",", me = ((J = te.find((pe) => pe.type === "decimal")) == null ? void 0 : J.value) ?? ".";
|
|
1303
|
+
return { group: ue, decimal: me };
|
|
1294
1304
|
} catch {
|
|
1295
1305
|
return { group: ",", decimal: "." };
|
|
1296
1306
|
}
|
|
1297
|
-
}, [
|
|
1298
|
-
if (!
|
|
1299
|
-
return
|
|
1300
|
-
const
|
|
1307
|
+
}, [y]), Te = ae ?? !!Ne.group, Xe = K(() => {
|
|
1308
|
+
if (!Te || ve === !1)
|
|
1309
|
+
return De;
|
|
1310
|
+
const U = Ne.decimal, J = Ne.group, te = De.replace(
|
|
1301
1311
|
new RegExp(`[${J.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`, "g"),
|
|
1302
1312
|
""
|
|
1303
|
-
), [
|
|
1304
|
-
if (!
|
|
1305
|
-
return
|
|
1306
|
-
const
|
|
1307
|
-
return
|
|
1308
|
-
}, [
|
|
1309
|
-
|
|
1310
|
-
},
|
|
1313
|
+
), [ue, me] = te.split(U);
|
|
1314
|
+
if (!ue)
|
|
1315
|
+
return te;
|
|
1316
|
+
const pe = ue.replace(/\B(?=(\d{3})+(?!\d))/g, J);
|
|
1317
|
+
return me != null ? `${pe}${U}${me}` : pe;
|
|
1318
|
+
}, [De, ve, Te, Ne]), Ee = K(() => e ? ie(e, { locale: y }) : "", [e, y]), he = typeof f == "string" ? f : void 0, Qe = `nice-money-input nice-money-input--${h} nice-money-input--label-${S} nice-money-input--error-${A}` + (he ? " nice-money-input--error" : "") + (z ? " nice-money-input--disabled" : "") + (g ? " nice-money-input--loading" : "") + (D ? ` ${D}` : ""), Ve = (U) => {
|
|
1319
|
+
q && U.key === "Enter" && I && (U.preventDefault(), I());
|
|
1320
|
+
}, We = S === "left" && P != null ? { width: typeof P == "number" ? `${P}px` : P, flex: "none" } : void 0, et = M != null ? {
|
|
1311
1321
|
width: typeof M == "number" ? `${M}px` : M,
|
|
1312
1322
|
flex: "none"
|
|
1313
1323
|
} : void 0;
|
|
1314
|
-
return
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1324
|
+
return L ? null : /* @__PURE__ */ _("div", { ref: p, className: Qe, style: T, title: ne, "data-testid": Y, children: [
|
|
1325
|
+
b && /* @__PURE__ */ _("label", { htmlFor: $, className: "nice-money-input__label", style: We, children: [
|
|
1326
|
+
b,
|
|
1327
|
+
m && /* @__PURE__ */ c("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
|
|
1318
1328
|
] }),
|
|
1319
|
-
/* @__PURE__ */
|
|
1320
|
-
!
|
|
1321
|
-
|
|
1329
|
+
/* @__PURE__ */ _("div", { className: "nice-money-input__row", style: et, children: [
|
|
1330
|
+
!d && /* @__PURE__ */ c(
|
|
1331
|
+
Ge,
|
|
1322
1332
|
{
|
|
1323
|
-
value:
|
|
1333
|
+
value: R,
|
|
1324
1334
|
compact: !0,
|
|
1325
|
-
options: i ? i.map(
|
|
1326
|
-
onChange: (
|
|
1327
|
-
disabled:
|
|
1335
|
+
options: i ? i.map(re).filter((U) => !!U) : void 0,
|
|
1336
|
+
onChange: (U) => a == null ? void 0 : a(U),
|
|
1337
|
+
disabled: z || C,
|
|
1328
1338
|
className: "nice-money-input__currency",
|
|
1329
|
-
"aria-label": "Currency"
|
|
1339
|
+
"aria-label": F("moneyInput.currency", "Currency")
|
|
1330
1340
|
}
|
|
1331
1341
|
),
|
|
1332
|
-
|
|
1333
|
-
|
|
1342
|
+
d && /* @__PURE__ */ c("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (de == null ? void 0 : de.symbol) ?? R }),
|
|
1343
|
+
B && /* @__PURE__ */ c(
|
|
1334
1344
|
"button",
|
|
1335
1345
|
{
|
|
1336
1346
|
type: "button",
|
|
1337
1347
|
className: "nice-money-input__step nice-money-input__step--down",
|
|
1338
|
-
onClick: () =>
|
|
1339
|
-
disabled:
|
|
1340
|
-
"aria-label": "Decrease amount",
|
|
1348
|
+
onClick: () => Ae(-xe),
|
|
1349
|
+
disabled: z || C || s != null && e != null && e.amount / Math.pow(10, ee) <= s,
|
|
1350
|
+
"aria-label": F("moneyInput.decreaseAmount", "Decrease amount"),
|
|
1341
1351
|
tabIndex: -1,
|
|
1342
1352
|
children: "−"
|
|
1343
1353
|
}
|
|
@@ -1345,244 +1355,242 @@ const qe = ie(function({
|
|
|
1345
1355
|
/* @__PURE__ */ c(
|
|
1346
1356
|
"input",
|
|
1347
1357
|
{
|
|
1348
|
-
id:
|
|
1349
|
-
name:
|
|
1358
|
+
id: $,
|
|
1359
|
+
name: X,
|
|
1350
1360
|
type: "text",
|
|
1351
1361
|
inputMode: "decimal",
|
|
1352
1362
|
autoComplete: "transaction-amount",
|
|
1353
1363
|
className: "nice-money-input__amount",
|
|
1354
|
-
value:
|
|
1355
|
-
onChange:
|
|
1356
|
-
onKeyDown:
|
|
1357
|
-
onFocus: (
|
|
1358
|
-
|
|
1364
|
+
value: Xe,
|
|
1365
|
+
onChange: Je,
|
|
1366
|
+
onKeyDown: Ve,
|
|
1367
|
+
onFocus: (U) => {
|
|
1368
|
+
Re(!0), Q == null || Q(U);
|
|
1359
1369
|
},
|
|
1360
|
-
onBlur: (
|
|
1361
|
-
|
|
1370
|
+
onBlur: (U) => {
|
|
1371
|
+
Re(!1), e && ge((e.amount / Math.pow(10, ee)).toFixed(ee)), Z == null || Z(U);
|
|
1362
1372
|
},
|
|
1363
|
-
placeholder:
|
|
1364
|
-
disabled:
|
|
1373
|
+
placeholder: N ?? `0${ee > 0 ? "." + "0".repeat(ee) : ""}`,
|
|
1374
|
+
disabled: z,
|
|
1365
1375
|
readOnly: C,
|
|
1366
|
-
required:
|
|
1367
|
-
"aria-invalid": !!
|
|
1368
|
-
"aria-describedby":
|
|
1376
|
+
required: m,
|
|
1377
|
+
"aria-invalid": !!he,
|
|
1378
|
+
"aria-describedby": he || u ? `${$}-help` : void 0
|
|
1369
1379
|
}
|
|
1370
1380
|
),
|
|
1371
|
-
|
|
1381
|
+
B && /* @__PURE__ */ c(
|
|
1372
1382
|
"button",
|
|
1373
1383
|
{
|
|
1374
1384
|
type: "button",
|
|
1375
1385
|
className: "nice-money-input__step nice-money-input__step--up",
|
|
1376
|
-
onClick: () =>
|
|
1377
|
-
disabled:
|
|
1378
|
-
"aria-label": "Increase amount",
|
|
1386
|
+
onClick: () => Ae(xe),
|
|
1387
|
+
disabled: z || C || o != null && e != null && e.amount / Math.pow(10, ee) >= o,
|
|
1388
|
+
"aria-label": F("moneyInput.increaseAmount", "Increase amount"),
|
|
1379
1389
|
tabIndex: -1,
|
|
1380
1390
|
children: "+"
|
|
1381
1391
|
}
|
|
1382
1392
|
),
|
|
1383
|
-
|
|
1393
|
+
g && /* @__PURE__ */ c("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: /* @__PURE__ */ c(Pe, { name: "refresh", size: 14 }) })
|
|
1384
1394
|
] }),
|
|
1385
|
-
|
|
1386
|
-
(
|
|
1395
|
+
W && Ee && /* @__PURE__ */ c("span", { className: "nice-money-input__preview", "aria-live": "polite", children: Ee }),
|
|
1396
|
+
(he || u) && /* @__PURE__ */ c(
|
|
1387
1397
|
"span",
|
|
1388
1398
|
{
|
|
1389
|
-
id: `${
|
|
1390
|
-
className:
|
|
1391
|
-
children:
|
|
1399
|
+
id: `${$}-help`,
|
|
1400
|
+
className: he ? "nice-money-input__error" : "nice-money-input__helper",
|
|
1401
|
+
children: he ?? u
|
|
1392
1402
|
}
|
|
1393
1403
|
)
|
|
1394
1404
|
] });
|
|
1395
1405
|
}
|
|
1396
|
-
),
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
},
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
)
|
|
1436
|
-
(
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
)
|
|
1442
|
-
(
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
)
|
|
1449
|
-
(
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
/* @__PURE__ */ c("
|
|
1461
|
-
|
|
1462
|
-
/* @__PURE__ */
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
{
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
s && /* @__PURE__ */ c(Bt, { brand: T })
|
|
1483
|
-
] }),
|
|
1484
|
-
Y && /* @__PURE__ */ c("span", { id: `${O}-number-err`, className: "nice-credit-card__error", children: Y })
|
|
1485
|
-
] }) }),
|
|
1486
|
-
/* @__PURE__ */ h("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
|
|
1487
|
-
/* @__PURE__ */ h("label", { className: "nice-credit-card__field", children: [
|
|
1488
|
-
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: "Expiry" }),
|
|
1489
|
-
/* @__PURE__ */ c(
|
|
1490
|
-
"input",
|
|
1491
|
-
{
|
|
1492
|
-
id: `${O}-expiry`,
|
|
1493
|
-
type: "text",
|
|
1494
|
-
inputMode: "numeric",
|
|
1495
|
-
autoComplete: "cc-exp",
|
|
1496
|
-
placeholder: "MM/YY",
|
|
1497
|
-
value: e.expiry,
|
|
1498
|
-
onChange: Z,
|
|
1499
|
-
onBlur: () => {
|
|
1500
|
-
F((K) => ({ ...K, expiry: !0 }));
|
|
1501
|
-
const C = ze(e.expiry);
|
|
1502
|
-
C && C !== e.expiry && B({ expiry: C });
|
|
1503
|
-
},
|
|
1504
|
-
disabled: M,
|
|
1505
|
-
readOnly: R,
|
|
1506
|
-
"aria-invalid": !!m,
|
|
1507
|
-
"aria-describedby": m ? `${O}-expiry-err` : void 0,
|
|
1508
|
-
className: "nice-credit-card__input",
|
|
1509
|
-
maxLength: 5
|
|
1510
|
-
}
|
|
1511
|
-
),
|
|
1512
|
-
m && /* @__PURE__ */ c("span", { id: `${O}-expiry-err`, className: "nice-credit-card__error", children: m })
|
|
1513
|
-
] }),
|
|
1514
|
-
/* @__PURE__ */ h("label", { className: "nice-credit-card__field", children: [
|
|
1515
|
-
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: T === "amex" ? "CID" : "CVC" }),
|
|
1516
|
-
/* @__PURE__ */ c(
|
|
1517
|
-
"input",
|
|
1518
|
-
{
|
|
1519
|
-
id: `${O}-cvc`,
|
|
1520
|
-
type: "text",
|
|
1521
|
-
inputMode: "numeric",
|
|
1522
|
-
autoComplete: "cc-csc",
|
|
1523
|
-
placeholder: "•".repeat(ye(T)),
|
|
1524
|
-
value: e.cvc,
|
|
1525
|
-
onChange: U,
|
|
1526
|
-
onBlur: () => F((C) => ({ ...C, cvc: !0 })),
|
|
1527
|
-
disabled: M,
|
|
1528
|
-
readOnly: R,
|
|
1529
|
-
"aria-invalid": !!L,
|
|
1530
|
-
"aria-describedby": L ? `${O}-cvc-err` : void 0,
|
|
1531
|
-
className: "nice-credit-card__input",
|
|
1532
|
-
maxLength: ye(T)
|
|
1533
|
-
}
|
|
1534
|
-
),
|
|
1535
|
-
L && /* @__PURE__ */ c("span", { id: `${O}-cvc-err`, className: "nice-credit-card__error", children: L })
|
|
1536
|
-
] })
|
|
1406
|
+
), Bt = { number: "", expiry: "", cvc: "" }, Lt = /* @__PURE__ */ se(function({
|
|
1407
|
+
value: e = Bt,
|
|
1408
|
+
onChange: r,
|
|
1409
|
+
showHolderName: n = !0,
|
|
1410
|
+
requireHolderName: a,
|
|
1411
|
+
showPostalCode: i = !1,
|
|
1412
|
+
acceptedBrands: d,
|
|
1413
|
+
showBrandIcon: s = !0,
|
|
1414
|
+
size: o = "md",
|
|
1415
|
+
disabled: l,
|
|
1416
|
+
readOnly: y,
|
|
1417
|
+
loading: N,
|
|
1418
|
+
accessMode: b,
|
|
1419
|
+
label: u,
|
|
1420
|
+
helperText: f,
|
|
1421
|
+
error: h,
|
|
1422
|
+
required: w,
|
|
1423
|
+
className: x,
|
|
1424
|
+
style: m,
|
|
1425
|
+
id: g,
|
|
1426
|
+
title: v,
|
|
1427
|
+
"data-testid": S
|
|
1428
|
+
}, A) {
|
|
1429
|
+
const { t: P } = oe(), M = b === "hidden", q = l || b === "disabled" || N, I = y || b === "readOnly", W = _e(), B = g ?? `nice-cc-${W}`, [D, T] = H({
|
|
1430
|
+
number: !1,
|
|
1431
|
+
expiry: !1,
|
|
1432
|
+
cvc: !1,
|
|
1433
|
+
holder: !1,
|
|
1434
|
+
postal: !1
|
|
1435
|
+
}), O = K(() => ke(e.number), [e.number]), X = K(
|
|
1436
|
+
() => qe(e, { requireHolder: a ?? n }),
|
|
1437
|
+
[e, a, n]
|
|
1438
|
+
), ne = !d || d.includes(O) || O === "unknown", Y = j(
|
|
1439
|
+
(C) => {
|
|
1440
|
+
const L = { ...e, ...C }, le = qe(L, { requireHolder: a ?? n });
|
|
1441
|
+
r == null || r(L, le);
|
|
1442
|
+
},
|
|
1443
|
+
[e, a, n, r]
|
|
1444
|
+
), Z = j(
|
|
1445
|
+
(C) => {
|
|
1446
|
+
const L = C.target.value.replace(/\D/g, "").slice(0, 19);
|
|
1447
|
+
Y({ number: L });
|
|
1448
|
+
},
|
|
1449
|
+
[Y]
|
|
1450
|
+
), Q = j(
|
|
1451
|
+
(C) => {
|
|
1452
|
+
const L = C.target.value.replace(/\D/g, "").slice(0, 4);
|
|
1453
|
+
let le = L;
|
|
1454
|
+
L.length >= 3 ? le = `${L.slice(0, 2)}/${L.slice(2)}` : L.length === 2 && (le = `${L}/`), Y({ expiry: le });
|
|
1455
|
+
},
|
|
1456
|
+
[Y]
|
|
1457
|
+
), ae = j(
|
|
1458
|
+
(C) => {
|
|
1459
|
+
const L = C.target.value.replace(/\D/g, "").slice(0, be(O));
|
|
1460
|
+
Y({ cvc: L });
|
|
1461
|
+
},
|
|
1462
|
+
[O, Y]
|
|
1463
|
+
), E = K(() => mt(e.number, O), [e.number, O]), k = D.number && e.number.length > 0 && (ze(e.number) ? ne ? void 0 : "Card brand not accepted" : X.errors.number), p = D.expiry && e.expiry.length > 0 && !Ye(e.expiry) ? X.errors.expiry : void 0, F = D.cvc && e.cvc.length > 0 && e.cvc.length !== be(O) ? X.errors.cvc : void 0, z = `nice-credit-card nice-credit-card--${o}` + (q ? " nice-credit-card--disabled" : "") + (N ? " nice-credit-card--loading" : "") + (h ? " nice-credit-card--error" : "") + (x ? ` ${x}` : "");
|
|
1464
|
+
return M ? null : /* @__PURE__ */ _("div", { ref: A, className: z, style: m, title: v, "data-testid": S, children: [
|
|
1465
|
+
u && /* @__PURE__ */ _("div", { className: "nice-credit-card__title", children: [
|
|
1466
|
+
u,
|
|
1467
|
+
w && /* @__PURE__ */ c("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
|
|
1468
|
+
] }),
|
|
1469
|
+
/* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ _("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
|
|
1470
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: P("creditCardInput.cardNumber", "Card number") }),
|
|
1471
|
+
/* @__PURE__ */ _("span", { className: "nice-credit-card__input-wrapper", children: [
|
|
1472
|
+
/* @__PURE__ */ c(
|
|
1473
|
+
"input",
|
|
1474
|
+
{
|
|
1475
|
+
id: `${B}-number`,
|
|
1476
|
+
type: "text",
|
|
1477
|
+
inputMode: "numeric",
|
|
1478
|
+
autoComplete: "cc-number",
|
|
1479
|
+
placeholder: O === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
|
|
1480
|
+
value: E,
|
|
1481
|
+
onChange: Z,
|
|
1482
|
+
onBlur: () => T((C) => ({ ...C, number: !0 })),
|
|
1483
|
+
disabled: q,
|
|
1484
|
+
readOnly: I,
|
|
1485
|
+
"aria-invalid": !!k,
|
|
1486
|
+
"aria-describedby": k ? `${B}-number-err` : void 0,
|
|
1487
|
+
className: "nice-credit-card__input",
|
|
1488
|
+
maxLength: O === "amex" ? 17 : 23
|
|
1489
|
+
}
|
|
1490
|
+
),
|
|
1491
|
+
s && /* @__PURE__ */ c(Ht, { brand: O })
|
|
1537
1492
|
] }),
|
|
1538
|
-
|
|
1539
|
-
|
|
1493
|
+
k && /* @__PURE__ */ c("span", { id: `${B}-number-err`, className: "nice-credit-card__error", children: k })
|
|
1494
|
+
] }) }),
|
|
1495
|
+
/* @__PURE__ */ _("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
|
|
1496
|
+
/* @__PURE__ */ _("label", { className: "nice-credit-card__field", children: [
|
|
1497
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: P("creditCardInput.expiry", "Expiry") }),
|
|
1540
1498
|
/* @__PURE__ */ c(
|
|
1541
1499
|
"input",
|
|
1542
1500
|
{
|
|
1543
|
-
id: `${
|
|
1501
|
+
id: `${B}-expiry`,
|
|
1544
1502
|
type: "text",
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1503
|
+
inputMode: "numeric",
|
|
1504
|
+
autoComplete: "cc-exp",
|
|
1505
|
+
placeholder: P("creditCardInput.mmYy", "MM/YY"),
|
|
1506
|
+
value: e.expiry,
|
|
1507
|
+
onChange: Q,
|
|
1508
|
+
onBlur: () => {
|
|
1509
|
+
T((L) => ({ ...L, expiry: !0 }));
|
|
1510
|
+
const C = je(e.expiry);
|
|
1511
|
+
C && C !== e.expiry && Y({ expiry: C });
|
|
1512
|
+
},
|
|
1513
|
+
disabled: q,
|
|
1514
|
+
readOnly: I,
|
|
1515
|
+
"aria-invalid": !!p,
|
|
1516
|
+
"aria-describedby": p ? `${B}-expiry-err` : void 0,
|
|
1552
1517
|
className: "nice-credit-card__input",
|
|
1553
|
-
maxLength:
|
|
1518
|
+
maxLength: 5
|
|
1554
1519
|
}
|
|
1555
|
-
)
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1520
|
+
),
|
|
1521
|
+
p && /* @__PURE__ */ c("span", { id: `${B}-expiry-err`, className: "nice-credit-card__error", children: p })
|
|
1522
|
+
] }),
|
|
1523
|
+
/* @__PURE__ */ _("label", { className: "nice-credit-card__field", children: [
|
|
1524
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: O === "amex" ? P("creditCardInput.cid", "CID") : P("creditCardInput.cvc", "CVC") }),
|
|
1559
1525
|
/* @__PURE__ */ c(
|
|
1560
1526
|
"input",
|
|
1561
1527
|
{
|
|
1562
|
-
id: `${
|
|
1528
|
+
id: `${B}-cvc`,
|
|
1563
1529
|
type: "text",
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1530
|
+
inputMode: "numeric",
|
|
1531
|
+
autoComplete: "cc-csc",
|
|
1532
|
+
placeholder: "•".repeat(be(O)),
|
|
1533
|
+
value: e.cvc,
|
|
1534
|
+
onChange: ae,
|
|
1535
|
+
onBlur: () => T((C) => ({ ...C, cvc: !0 })),
|
|
1536
|
+
disabled: q,
|
|
1537
|
+
readOnly: I,
|
|
1538
|
+
"aria-invalid": !!F,
|
|
1539
|
+
"aria-describedby": F ? `${B}-cvc-err` : void 0,
|
|
1570
1540
|
className: "nice-credit-card__input",
|
|
1571
|
-
maxLength:
|
|
1541
|
+
maxLength: be(O)
|
|
1572
1542
|
}
|
|
1573
|
-
)
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1543
|
+
),
|
|
1544
|
+
F && /* @__PURE__ */ c("span", { id: `${B}-cvc-err`, className: "nice-credit-card__error", children: F })
|
|
1545
|
+
] })
|
|
1546
|
+
] }),
|
|
1547
|
+
n && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ _("label", { className: "nice-credit-card__field", children: [
|
|
1548
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: P("creditCardInput.cardholderName", "Cardholder name") }),
|
|
1549
|
+
/* @__PURE__ */ c(
|
|
1550
|
+
"input",
|
|
1577
1551
|
{
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1552
|
+
id: `${B}-holder`,
|
|
1553
|
+
type: "text",
|
|
1554
|
+
autoComplete: "cc-name",
|
|
1555
|
+
placeholder: P("creditCardInput.janeDoe", "Jane Doe"),
|
|
1556
|
+
value: e.holderName ?? "",
|
|
1557
|
+
onChange: (C) => Y({ holderName: C.target.value }),
|
|
1558
|
+
onBlur: () => T((C) => ({ ...C, holder: !0 })),
|
|
1559
|
+
disabled: q,
|
|
1560
|
+
readOnly: I,
|
|
1561
|
+
className: "nice-credit-card__input",
|
|
1562
|
+
maxLength: 120
|
|
1581
1563
|
}
|
|
1582
1564
|
)
|
|
1583
|
-
] })
|
|
1584
|
-
|
|
1585
|
-
|
|
1565
|
+
] }) }),
|
|
1566
|
+
i && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ _("label", { className: "nice-credit-card__field", children: [
|
|
1567
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: P("creditCardInput.postalCode", "Postal code") }),
|
|
1568
|
+
/* @__PURE__ */ c(
|
|
1569
|
+
"input",
|
|
1570
|
+
{
|
|
1571
|
+
id: `${B}-postal`,
|
|
1572
|
+
type: "text",
|
|
1573
|
+
autoComplete: "postal-code",
|
|
1574
|
+
value: e.postalCode ?? "",
|
|
1575
|
+
onChange: (C) => Y({ postalCode: C.target.value }),
|
|
1576
|
+
onBlur: () => T((C) => ({ ...C, postal: !0 })),
|
|
1577
|
+
disabled: q,
|
|
1578
|
+
readOnly: I,
|
|
1579
|
+
className: "nice-credit-card__input",
|
|
1580
|
+
maxLength: 16
|
|
1581
|
+
}
|
|
1582
|
+
)
|
|
1583
|
+
] }) }),
|
|
1584
|
+
(h || f) && /* @__PURE__ */ c(
|
|
1585
|
+
"div",
|
|
1586
|
+
{
|
|
1587
|
+
className: h ? "nice-credit-card__form-error" : "nice-credit-card__helper",
|
|
1588
|
+
role: h ? "alert" : void 0,
|
|
1589
|
+
children: h ?? f
|
|
1590
|
+
}
|
|
1591
|
+
)
|
|
1592
|
+
] });
|
|
1593
|
+
}), Ke = {
|
|
1586
1594
|
visa: "VISA",
|
|
1587
1595
|
mastercard: "MasterCard",
|
|
1588
1596
|
amex: "AMEX",
|
|
@@ -1596,7 +1604,7 @@ const qe = ie(function({
|
|
|
1596
1604
|
hipercard: "Hipercard",
|
|
1597
1605
|
unknown: ""
|
|
1598
1606
|
};
|
|
1599
|
-
function
|
|
1607
|
+
function Ht({ brand: t }) {
|
|
1600
1608
|
return t === "unknown" ? null : /* @__PURE__ */ c(
|
|
1601
1609
|
"span",
|
|
1602
1610
|
{
|
|
@@ -1606,136 +1614,134 @@ function Bt({ brand: t }) {
|
|
|
1606
1614
|
}
|
|
1607
1615
|
);
|
|
1608
1616
|
}
|
|
1609
|
-
const
|
|
1617
|
+
const yr = /* @__PURE__ */ se(
|
|
1610
1618
|
function({
|
|
1611
1619
|
processor: e,
|
|
1612
1620
|
amount: r,
|
|
1613
|
-
editableAmount:
|
|
1614
|
-
customer:
|
|
1621
|
+
editableAmount: n,
|
|
1622
|
+
customer: a,
|
|
1615
1623
|
currencies: i,
|
|
1616
|
-
description:
|
|
1624
|
+
description: d,
|
|
1617
1625
|
metadata: s,
|
|
1618
1626
|
autoCapture: o = !0,
|
|
1619
|
-
submitLabel: l
|
|
1620
|
-
onSuccess:
|
|
1621
|
-
onError:
|
|
1622
|
-
consents:
|
|
1623
|
-
className:
|
|
1624
|
-
style:
|
|
1625
|
-
},
|
|
1626
|
-
const [
|
|
1627
|
-
var
|
|
1628
|
-
const
|
|
1629
|
-
return
|
|
1630
|
-
}, [e,
|
|
1631
|
-
var
|
|
1632
|
-
const
|
|
1633
|
-
return
|
|
1634
|
-
}, [e,
|
|
1635
|
-
async (
|
|
1636
|
-
if (
|
|
1637
|
-
|
|
1627
|
+
submitLabel: l,
|
|
1628
|
+
onSuccess: y,
|
|
1629
|
+
onError: N,
|
|
1630
|
+
consents: b,
|
|
1631
|
+
className: u,
|
|
1632
|
+
style: f
|
|
1633
|
+
}, h) {
|
|
1634
|
+
const { t: w } = oe(), x = l ?? w("paymentForm.pay", "Pay"), [m, g] = H(r), [v, S] = H(r.currency), [A, P] = H({ number: "", expiry: "", cvc: "" }), [M, q] = H(null), [I, W] = H(!1), [B, D] = H(null), T = Kt(e), O = K(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(m.currency.toUpperCase()), [e, m.currency]), X = K(() => {
|
|
1635
|
+
var k;
|
|
1636
|
+
const E = (k = e.minimums) == null ? void 0 : k[m.currency.toUpperCase()];
|
|
1637
|
+
return E == null || m.amount >= E;
|
|
1638
|
+
}, [e, m]), ne = K(() => {
|
|
1639
|
+
var k;
|
|
1640
|
+
const E = (k = e.minimums) == null ? void 0 : k[m.currency.toUpperCase()];
|
|
1641
|
+
return E == null ? null : { amount: E, currency: m.currency };
|
|
1642
|
+
}, [e, m.currency]), Y = !!(M != null && M.isValid), Z = !I && O && X && Y, Q = j(
|
|
1643
|
+
async (E) => {
|
|
1644
|
+
if (E.preventDefault(), !!Z) {
|
|
1645
|
+
D(null), W(!0);
|
|
1638
1646
|
try {
|
|
1639
|
-
const
|
|
1640
|
-
amount:
|
|
1641
|
-
card:
|
|
1642
|
-
customer:
|
|
1643
|
-
description:
|
|
1647
|
+
const k = {
|
|
1648
|
+
amount: m,
|
|
1649
|
+
card: A,
|
|
1650
|
+
customer: a,
|
|
1651
|
+
description: d,
|
|
1644
1652
|
metadata: s,
|
|
1645
|
-
idempotencyKey:
|
|
1646
|
-
},
|
|
1647
|
-
if (o &&
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1653
|
+
idempotencyKey: zt()
|
|
1654
|
+
}, p = await T.authorize(k);
|
|
1655
|
+
if (o && p.status === "authorized") {
|
|
1656
|
+
const F = await T.capture(p.id, m);
|
|
1657
|
+
y == null || y(F);
|
|
1650
1658
|
} else
|
|
1651
|
-
|
|
1652
|
-
} catch (
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1659
|
+
y == null || y(p);
|
|
1660
|
+
} catch (k) {
|
|
1661
|
+
const p = k instanceof Error ? k : new Error(String(k));
|
|
1662
|
+
D(p.message), N == null || N(p);
|
|
1655
1663
|
} finally {
|
|
1656
|
-
|
|
1664
|
+
W(!1);
|
|
1657
1665
|
}
|
|
1658
1666
|
}
|
|
1659
1667
|
},
|
|
1660
1668
|
[
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1669
|
+
Z,
|
|
1670
|
+
m,
|
|
1671
|
+
A,
|
|
1672
|
+
a,
|
|
1673
|
+
d,
|
|
1666
1674
|
s,
|
|
1667
1675
|
o,
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1676
|
+
T,
|
|
1677
|
+
y,
|
|
1678
|
+
N
|
|
1671
1679
|
]
|
|
1672
|
-
),
|
|
1673
|
-
return /* @__PURE__ */
|
|
1680
|
+
), ae = re(m.currency);
|
|
1681
|
+
return /* @__PURE__ */ _(
|
|
1674
1682
|
"form",
|
|
1675
1683
|
{
|
|
1676
|
-
ref:
|
|
1677
|
-
className: "nice-payment-form" + (
|
|
1678
|
-
style:
|
|
1679
|
-
onSubmit:
|
|
1680
|
-
"aria-busy":
|
|
1684
|
+
ref: h,
|
|
1685
|
+
className: "nice-payment-form" + (u ? ` ${u}` : ""),
|
|
1686
|
+
style: f,
|
|
1687
|
+
onSubmit: Q,
|
|
1688
|
+
"aria-busy": I,
|
|
1681
1689
|
children: [
|
|
1682
|
-
/* @__PURE__ */ c("div", { className: "nice-payment-form__amount", children:
|
|
1683
|
-
|
|
1690
|
+
/* @__PURE__ */ c("div", { className: "nice-payment-form__amount", children: n ? /* @__PURE__ */ c(
|
|
1691
|
+
Ze,
|
|
1684
1692
|
{
|
|
1685
|
-
label: "Amount",
|
|
1686
|
-
value:
|
|
1687
|
-
currency:
|
|
1693
|
+
label: w("paymentForm.amount", "Amount"),
|
|
1694
|
+
value: m,
|
|
1695
|
+
currency: v,
|
|
1688
1696
|
currencies: i,
|
|
1689
|
-
onChange: (
|
|
1690
|
-
onCurrencyChange: (
|
|
1691
|
-
|
|
1697
|
+
onChange: (E) => E && g(E),
|
|
1698
|
+
onCurrencyChange: (E) => {
|
|
1699
|
+
S(E), g((k) => ({ ...k, currency: E }));
|
|
1692
1700
|
},
|
|
1693
|
-
disabled:
|
|
1701
|
+
disabled: I,
|
|
1694
1702
|
required: !0,
|
|
1695
1703
|
showFormattedPreview: !0
|
|
1696
1704
|
}
|
|
1697
|
-
) : /* @__PURE__ */
|
|
1698
|
-
/* @__PURE__ */ c("span", { className: "nice-payment-form__total-label", children: "Total" }),
|
|
1699
|
-
/* @__PURE__ */ c(
|
|
1705
|
+
) : /* @__PURE__ */ _("div", { className: "nice-payment-form__total", children: [
|
|
1706
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-form__total-label", children: w("paymentForm.total", "Total") }),
|
|
1707
|
+
/* @__PURE__ */ c(Oe, { value: m })
|
|
1700
1708
|
] }) }),
|
|
1701
|
-
|
|
1709
|
+
d && /* @__PURE__ */ c("p", { className: "nice-payment-form__description", children: d }),
|
|
1702
1710
|
/* @__PURE__ */ c("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ c(
|
|
1703
|
-
|
|
1711
|
+
Lt,
|
|
1704
1712
|
{
|
|
1705
|
-
value:
|
|
1706
|
-
onChange: (
|
|
1707
|
-
|
|
1713
|
+
value: A,
|
|
1714
|
+
onChange: (E, k) => {
|
|
1715
|
+
P(E), q(k);
|
|
1708
1716
|
},
|
|
1709
|
-
disabled:
|
|
1717
|
+
disabled: I
|
|
1710
1718
|
}
|
|
1711
1719
|
) }),
|
|
1712
|
-
!
|
|
1713
|
-
|
|
1714
|
-
"
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
e.name,
|
|
1721
|
-
" is ",
|
|
1722
|
-
/* @__PURE__ */ c(qe, { value: Q }),
|
|
1720
|
+
!O && /* @__PURE__ */ c("div", { className: "nice-payment-form__warning", role: "alert", children: w("paymentForm.doesNotAccept", "{provider} does not accept {currency}.").replace("{provider}", String(e.name)).replace("{currency}", String((ae == null ? void 0 : ae.name) ?? m.currency)) }),
|
|
1721
|
+
!X && ne && /* @__PURE__ */ _("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1722
|
+
w("paymentForm.minimumChargeForIs", "Minimum charge for {name} is").replace(
|
|
1723
|
+
"{name}",
|
|
1724
|
+
String(e.name)
|
|
1725
|
+
),
|
|
1726
|
+
" ",
|
|
1727
|
+
/* @__PURE__ */ c(Oe, { value: ne }),
|
|
1723
1728
|
"."
|
|
1724
1729
|
] }),
|
|
1725
|
-
|
|
1726
|
-
|
|
1730
|
+
b && /* @__PURE__ */ c("div", { className: "nice-payment-form__consents", children: b }),
|
|
1731
|
+
B && /* @__PURE__ */ c("div", { className: "nice-payment-form__error", role: "alert", children: B }),
|
|
1727
1732
|
/* @__PURE__ */ c(
|
|
1728
1733
|
"button",
|
|
1729
1734
|
{
|
|
1730
1735
|
type: "submit",
|
|
1731
1736
|
className: "nice-payment-form__submit",
|
|
1732
|
-
disabled: !
|
|
1733
|
-
"aria-disabled": !
|
|
1734
|
-
children:
|
|
1737
|
+
disabled: !Z,
|
|
1738
|
+
"aria-disabled": !Z,
|
|
1739
|
+
children: I ? w("paymentForm.processing", "Processing…") : x
|
|
1735
1740
|
}
|
|
1736
1741
|
),
|
|
1737
|
-
/* @__PURE__ */
|
|
1738
|
-
"Secured by
|
|
1742
|
+
/* @__PURE__ */ _("p", { className: "nice-payment-form__processor", children: [
|
|
1743
|
+
w("paymentForm.securedBy", "Secured by"),
|
|
1744
|
+
" ",
|
|
1739
1745
|
/* @__PURE__ */ c("strong", { children: e.name })
|
|
1740
1746
|
] })
|
|
1741
1747
|
]
|
|
@@ -1743,285 +1749,297 @@ const dr = ie(
|
|
|
1743
1749
|
);
|
|
1744
1750
|
}
|
|
1745
1751
|
);
|
|
1746
|
-
function
|
|
1752
|
+
function zt() {
|
|
1747
1753
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
1748
1754
|
}
|
|
1749
|
-
const
|
|
1750
|
-
price: e,
|
|
1751
|
-
originalPrice: r,
|
|
1752
|
-
period: a,
|
|
1753
|
-
prefix: n,
|
|
1754
|
-
suffix: i,
|
|
1755
|
-
showDiscountBadge: u = !0,
|
|
1756
|
-
size: s = "md",
|
|
1757
|
-
locale: o,
|
|
1758
|
-
className: l,
|
|
1759
|
-
style: p
|
|
1760
|
-
}, v) {
|
|
1761
|
-
const y = r && r.currency === e.currency && r.amount > e.amount, d = q(() => !y || !r ? null : Math.round((r.amount - e.amount) / r.amount * 100), [y, r, e.amount]), b = `nice-price-tag nice-price-tag--${s}` + (l ? ` ${l}` : "");
|
|
1762
|
-
return /* @__PURE__ */ h("div", { ref: v, className: b, style: p, children: [
|
|
1763
|
-
n && /* @__PURE__ */ c("span", { className: "nice-price-tag__prefix", children: n }),
|
|
1764
|
-
/* @__PURE__ */ h("span", { className: "nice-price-tag__main", children: [
|
|
1765
|
-
/* @__PURE__ */ c("span", { className: "nice-price-tag__amount", children: ce(e, { locale: o }) }),
|
|
1766
|
-
a && /* @__PURE__ */ c("span", { className: "nice-price-tag__period", children: a })
|
|
1767
|
-
] }),
|
|
1768
|
-
y && r && /* @__PURE__ */ c("span", { className: "nice-price-tag__original", "aria-label": "Original price", children: /* @__PURE__ */ c("s", { children: ce(r, { locale: o }) }) }),
|
|
1769
|
-
y && u && d != null && d > 0 && /* @__PURE__ */ h("span", { className: "nice-price-tag__discount", "aria-label": `${d} percent off`, children: [
|
|
1770
|
-
"−",
|
|
1771
|
-
d,
|
|
1772
|
-
"%"
|
|
1773
|
-
] }),
|
|
1774
|
-
i && /* @__PURE__ */ c("span", { className: "nice-price-tag__suffix", children: i })
|
|
1775
|
-
] });
|
|
1776
|
-
}), zt = { amount: 0, currency: "USD" }, mr = ie(
|
|
1755
|
+
const hr = /* @__PURE__ */ se(
|
|
1777
1756
|
function({
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1757
|
+
price: e,
|
|
1758
|
+
originalPrice: r,
|
|
1759
|
+
period: n,
|
|
1760
|
+
prefix: a,
|
|
1761
|
+
suffix: i,
|
|
1762
|
+
showDiscountBadge: d = !0,
|
|
1763
|
+
size: s = "md",
|
|
1785
1764
|
locale: o,
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
Ye,
|
|
1819
|
-
{
|
|
1820
|
-
label: "From",
|
|
1821
|
-
value: d,
|
|
1822
|
-
onChange: (A) => A && b(A),
|
|
1823
|
-
currency: d.currency,
|
|
1824
|
-
onCurrencyChange: (A) => b({ ...d, currency: A }),
|
|
1825
|
-
showFormattedPreview: !1
|
|
1826
|
-
}
|
|
1827
|
-
) }),
|
|
1828
|
-
/* @__PURE__ */ h("div", { className: "nice-currency-converter__row", children: [
|
|
1829
|
-
/* @__PURE__ */ c("label", { className: "nice-currency-converter__label", children: "To" }),
|
|
1830
|
-
/* @__PURE__ */ h("div", { className: "nice-currency-converter__output", children: [
|
|
1831
|
-
/* @__PURE__ */ c(
|
|
1832
|
-
je,
|
|
1833
|
-
{
|
|
1834
|
-
value: f,
|
|
1835
|
-
onChange: (A) => g(A),
|
|
1836
|
-
compact: !0
|
|
1837
|
-
}
|
|
1838
|
-
),
|
|
1839
|
-
/* @__PURE__ */ c("span", { className: "nice-currency-converter__amount", children: w ? "…" : N ? "—" : _ ? ce(_, { locale: o }) : "" })
|
|
1840
|
-
] })
|
|
1841
|
-
] }),
|
|
1842
|
-
l && x && /* @__PURE__ */ h("p", { className: "nice-currency-converter__rate", children: [
|
|
1843
|
-
"1 ",
|
|
1844
|
-
d.currency,
|
|
1845
|
-
" = ",
|
|
1846
|
-
ce(x, { locale: o }),
|
|
1847
|
-
" ",
|
|
1848
|
-
/* @__PURE__ */ h("span", { className: "nice-currency-converter__inverse", children: [
|
|
1849
|
-
"· 1 ",
|
|
1850
|
-
f,
|
|
1851
|
-
" =",
|
|
1852
|
-
" ",
|
|
1853
|
-
ce(re(1 / Be(x), d.currency), { locale: o })
|
|
1854
|
-
] })
|
|
1855
|
-
] }),
|
|
1856
|
-
N && /* @__PURE__ */ c("p", { className: "nice-currency-converter__error", role: "alert", children: N.message })
|
|
1857
|
-
]
|
|
1858
|
-
}
|
|
1859
|
-
);
|
|
1765
|
+
className: l,
|
|
1766
|
+
style: y
|
|
1767
|
+
}, N) {
|
|
1768
|
+
const { t: b } = oe(), u = r && r.currency === e.currency && r.amount > e.amount, f = K(() => !u || !r ? null : Math.round((r.amount - e.amount) / r.amount * 100), [u, r, e.amount]), h = `nice-price-tag nice-price-tag--${s}` + (l ? ` ${l}` : "");
|
|
1769
|
+
return /* @__PURE__ */ _("div", { ref: N, className: h, style: y, children: [
|
|
1770
|
+
a && /* @__PURE__ */ c("span", { className: "nice-price-tag__prefix", children: a }),
|
|
1771
|
+
/* @__PURE__ */ _("span", { className: "nice-price-tag__main", children: [
|
|
1772
|
+
/* @__PURE__ */ c("span", { className: "nice-price-tag__amount", children: ie(e, { locale: o }) }),
|
|
1773
|
+
n && /* @__PURE__ */ c("span", { className: "nice-price-tag__period", children: n })
|
|
1774
|
+
] }),
|
|
1775
|
+
u && r && /* @__PURE__ */ c(
|
|
1776
|
+
"span",
|
|
1777
|
+
{
|
|
1778
|
+
className: "nice-price-tag__original",
|
|
1779
|
+
"aria-label": b("priceTag.originalPrice", "Original price"),
|
|
1780
|
+
children: /* @__PURE__ */ c("s", { children: ie(r, { locale: o }) })
|
|
1781
|
+
}
|
|
1782
|
+
),
|
|
1783
|
+
u && d && f != null && f > 0 && /* @__PURE__ */ _(
|
|
1784
|
+
"span",
|
|
1785
|
+
{
|
|
1786
|
+
className: "nice-price-tag__discount",
|
|
1787
|
+
"aria-label": b("priceTag.percentOff", "{pct} percent off").replace("{pct}", String(f)),
|
|
1788
|
+
children: [
|
|
1789
|
+
"−",
|
|
1790
|
+
f,
|
|
1791
|
+
"%"
|
|
1792
|
+
]
|
|
1793
|
+
}
|
|
1794
|
+
),
|
|
1795
|
+
i && /* @__PURE__ */ c("span", { className: "nice-price-tag__suffix", children: i })
|
|
1796
|
+
] });
|
|
1860
1797
|
}
|
|
1861
|
-
)
|
|
1862
|
-
|
|
1798
|
+
), jt = { amount: 0, currency: "USD" }, br = /* @__PURE__ */ se(function({
|
|
1799
|
+
source: e,
|
|
1800
|
+
defaultSource: r,
|
|
1801
|
+
onSourceChange: n,
|
|
1802
|
+
targetCurrency: a,
|
|
1803
|
+
defaultTargetCurrency: i,
|
|
1804
|
+
onTargetCurrencyChange: d,
|
|
1805
|
+
provider: s,
|
|
1806
|
+
locale: o,
|
|
1807
|
+
showRateLine: l = !0,
|
|
1808
|
+
className: y,
|
|
1809
|
+
style: N
|
|
1810
|
+
}, b) {
|
|
1811
|
+
const { t: u } = oe(), [f, h] = Me({
|
|
1812
|
+
value: e,
|
|
1813
|
+
defaultValue: r,
|
|
1814
|
+
fallbackValue: jt,
|
|
1815
|
+
onChange: n,
|
|
1816
|
+
componentName: "NiceCurrencyConverter"
|
|
1817
|
+
}), [w, x] = Me({
|
|
1818
|
+
value: a,
|
|
1819
|
+
defaultValue: i,
|
|
1820
|
+
fallbackValue: f.currency,
|
|
1821
|
+
onChange: d,
|
|
1822
|
+
componentName: "NiceCurrencyConverter"
|
|
1823
|
+
}), { converted: m, loading: g, error: v } = Ie(f, w, s), S = K(
|
|
1824
|
+
() => ({ amount: Math.pow(10, 2), currency: f.currency }),
|
|
1825
|
+
[f.currency]
|
|
1826
|
+
), { converted: A } = Ie(
|
|
1827
|
+
l ? S : null,
|
|
1828
|
+
w,
|
|
1829
|
+
s
|
|
1830
|
+
);
|
|
1831
|
+
return /* @__PURE__ */ _(
|
|
1832
|
+
"div",
|
|
1833
|
+
{
|
|
1834
|
+
ref: b,
|
|
1835
|
+
className: "nice-currency-converter" + (y ? ` ${y}` : ""),
|
|
1836
|
+
style: N,
|
|
1837
|
+
children: [
|
|
1838
|
+
/* @__PURE__ */ c("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ c(
|
|
1839
|
+
Ze,
|
|
1840
|
+
{
|
|
1841
|
+
label: u("currencyConverter.from", "From"),
|
|
1842
|
+
value: f,
|
|
1843
|
+
onChange: (P) => P && h(P),
|
|
1844
|
+
currency: f.currency,
|
|
1845
|
+
onCurrencyChange: (P) => h({ ...f, currency: P }),
|
|
1846
|
+
showFormattedPreview: !1
|
|
1847
|
+
}
|
|
1848
|
+
) }),
|
|
1849
|
+
/* @__PURE__ */ _("div", { className: "nice-currency-converter__row", children: [
|
|
1850
|
+
/* @__PURE__ */ c("label", { className: "nice-currency-converter__label", children: u("currencyConverter.to", "To") }),
|
|
1851
|
+
/* @__PURE__ */ _("div", { className: "nice-currency-converter__output", children: [
|
|
1852
|
+
/* @__PURE__ */ c(
|
|
1853
|
+
Ge,
|
|
1854
|
+
{
|
|
1855
|
+
value: w,
|
|
1856
|
+
onChange: (P) => x(P),
|
|
1857
|
+
compact: !0
|
|
1858
|
+
}
|
|
1859
|
+
),
|
|
1860
|
+
/* @__PURE__ */ c("span", { className: "nice-currency-converter__amount", children: g ? "…" : v ? "—" : m ? ie(m, { locale: o }) : "" })
|
|
1861
|
+
] })
|
|
1862
|
+
] }),
|
|
1863
|
+
l && A && /* @__PURE__ */ _("p", { className: "nice-currency-converter__rate", children: [
|
|
1864
|
+
"1 ",
|
|
1865
|
+
f.currency,
|
|
1866
|
+
" = ",
|
|
1867
|
+
ie(A, { locale: o }),
|
|
1868
|
+
" ",
|
|
1869
|
+
/* @__PURE__ */ _("span", { className: "nice-currency-converter__inverse", children: [
|
|
1870
|
+
"· 1 ",
|
|
1871
|
+
w,
|
|
1872
|
+
" =",
|
|
1873
|
+
" ",
|
|
1874
|
+
ie(ce(1 / He(A), f.currency), { locale: o })
|
|
1875
|
+
] })
|
|
1876
|
+
] }),
|
|
1877
|
+
v && /* @__PURE__ */ c("p", { className: "nice-currency-converter__error", role: "alert", children: v.message })
|
|
1878
|
+
]
|
|
1879
|
+
}
|
|
1880
|
+
);
|
|
1881
|
+
}), Yt = [];
|
|
1882
|
+
function Be(t) {
|
|
1863
1883
|
return { amount: Math.round(t.amount), currency: t.currency };
|
|
1864
1884
|
}
|
|
1865
|
-
const
|
|
1885
|
+
const fr = /* @__PURE__ */ se(
|
|
1866
1886
|
function({
|
|
1867
|
-
lines: e,
|
|
1887
|
+
lines: e = Yt,
|
|
1868
1888
|
locale: r,
|
|
1869
|
-
rounding:
|
|
1870
|
-
showTotals:
|
|
1889
|
+
rounding: n = "line",
|
|
1890
|
+
showTotals: a = !0,
|
|
1871
1891
|
showGrandTotal: i = !0,
|
|
1872
|
-
hideRateColumn:
|
|
1892
|
+
hideRateColumn: d = !1,
|
|
1873
1893
|
labels: s,
|
|
1874
1894
|
density: o = "comfortable",
|
|
1875
1895
|
className: l,
|
|
1876
|
-
style:
|
|
1877
|
-
id:
|
|
1878
|
-
},
|
|
1879
|
-
const
|
|
1880
|
-
label: (s == null ? void 0 : s.label) ?? "Item",
|
|
1896
|
+
style: y,
|
|
1897
|
+
id: N
|
|
1898
|
+
}, b) {
|
|
1899
|
+
const { t: u } = oe(), f = {
|
|
1900
|
+
label: (s == null ? void 0 : s.label) ?? u("taxBreakdown.item", "Item"),
|
|
1881
1901
|
rate: (s == null ? void 0 : s.rate) ?? "VAT",
|
|
1882
1902
|
net: (s == null ? void 0 : s.net) ?? "Net",
|
|
1883
1903
|
vat: (s == null ? void 0 : s.vat) ?? "Tax",
|
|
1884
1904
|
gross: (s == null ? void 0 : s.gross) ?? "Gross",
|
|
1885
1905
|
total: (s == null ? void 0 : s.total) ?? "Total"
|
|
1886
|
-
},
|
|
1887
|
-
if (
|
|
1888
|
-
const
|
|
1889
|
-
for (const
|
|
1890
|
-
let
|
|
1891
|
-
|
|
1906
|
+
}, h = K(() => {
|
|
1907
|
+
if (n === "total") {
|
|
1908
|
+
const m = /* @__PURE__ */ new Map();
|
|
1909
|
+
for (const v of e) {
|
|
1910
|
+
let S = m.get(v.vatRate);
|
|
1911
|
+
S || (S = [], m.set(v.vatRate, S)), S.push(v.netAmount);
|
|
1892
1912
|
}
|
|
1893
|
-
const
|
|
1894
|
-
for (const [
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1913
|
+
const g = [];
|
|
1914
|
+
for (const [v, S] of m) {
|
|
1915
|
+
const A = S.reduce((q, I) => ye(q, I), ce(0, S[0].currency)), P = Be(Se(A, v)), M = ye(A, P);
|
|
1916
|
+
g.push({ rate: v, net: A, vat: P, gross: M });
|
|
1897
1917
|
}
|
|
1898
|
-
return
|
|
1918
|
+
return g;
|
|
1899
1919
|
}
|
|
1900
|
-
return e.map((
|
|
1901
|
-
const
|
|
1902
|
-
return { label:
|
|
1920
|
+
return e.map((m) => {
|
|
1921
|
+
const g = Be(Se(m.netAmount, m.vatRate)), v = ye(m.netAmount, g);
|
|
1922
|
+
return { label: m.label, rate: m.vatRate, net: m.netAmount, vat: g, gross: v };
|
|
1903
1923
|
});
|
|
1904
|
-
}, [e,
|
|
1905
|
-
if (
|
|
1924
|
+
}, [e, n]), w = K(() => {
|
|
1925
|
+
if (h.length === 0)
|
|
1906
1926
|
return null;
|
|
1907
|
-
const
|
|
1908
|
-
let
|
|
1909
|
-
for (const
|
|
1910
|
-
|
|
1911
|
-
return { net:
|
|
1912
|
-
}, [
|
|
1913
|
-
return /* @__PURE__ */
|
|
1927
|
+
const m = h[0].net.currency;
|
|
1928
|
+
let g = ce(0, m), v = ce(0, m), S = ce(0, m);
|
|
1929
|
+
for (const A of h)
|
|
1930
|
+
g = ye(g, A.net), v = ye(v, A.vat), S = ye(S, A.gross);
|
|
1931
|
+
return { net: g, vat: v, gross: S };
|
|
1932
|
+
}, [h]), x = (m) => ie(m, { locale: r });
|
|
1933
|
+
return /* @__PURE__ */ _(
|
|
1914
1934
|
"table",
|
|
1915
1935
|
{
|
|
1916
|
-
ref:
|
|
1917
|
-
id:
|
|
1936
|
+
ref: b,
|
|
1937
|
+
id: N,
|
|
1918
1938
|
className: `nice-tax-breakdown nice-tax-breakdown--${o} ${l ?? ""}`,
|
|
1919
|
-
style:
|
|
1939
|
+
style: y,
|
|
1920
1940
|
role: "table",
|
|
1921
|
-
"aria-label":
|
|
1941
|
+
"aria-label": f.total,
|
|
1922
1942
|
children: [
|
|
1923
|
-
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */
|
|
1924
|
-
|
|
1925
|
-
!
|
|
1926
|
-
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children:
|
|
1927
|
-
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children:
|
|
1928
|
-
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children:
|
|
1943
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ _("tr", { children: [
|
|
1944
|
+
h.some((m) => m.label !== void 0) && /* @__PURE__ */ c("th", { scope: "col", children: f.label }),
|
|
1945
|
+
!d && /* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__rate", children: f.rate }),
|
|
1946
|
+
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: f.net }),
|
|
1947
|
+
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: f.vat }),
|
|
1948
|
+
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: f.gross })
|
|
1929
1949
|
] }) }),
|
|
1930
|
-
/* @__PURE__ */ c("tbody", { children:
|
|
1931
|
-
|
|
1932
|
-
!
|
|
1933
|
-
(
|
|
1950
|
+
/* @__PURE__ */ c("tbody", { children: h.map((m, g) => /* @__PURE__ */ _("tr", { children: [
|
|
1951
|
+
h.some((v) => v.label !== void 0) && /* @__PURE__ */ c("td", { children: m.label ?? "" }),
|
|
1952
|
+
!d && /* @__PURE__ */ _("td", { className: "nice-tax-breakdown__rate", children: [
|
|
1953
|
+
(m.rate * 100).toLocaleString(r, { maximumFractionDigits: 2 }),
|
|
1934
1954
|
"%"
|
|
1935
1955
|
] }),
|
|
1936
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1937
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1938
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1939
|
-
] }, `${
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
!
|
|
1943
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1944
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1945
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children:
|
|
1956
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: x(m.net) }),
|
|
1957
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: x(m.vat) }),
|
|
1958
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: x(m.gross) })
|
|
1959
|
+
] }, `${m.rate}-${g}`)) }),
|
|
1960
|
+
a && w && /* @__PURE__ */ c("tfoot", { children: i && /* @__PURE__ */ _("tr", { className: "nice-tax-breakdown__totals", children: [
|
|
1961
|
+
h.some((m) => m.label !== void 0) && /* @__PURE__ */ c("td", { children: f.total }),
|
|
1962
|
+
!d && /* @__PURE__ */ c("td", { children: h.some((m) => m.label !== void 0) ? null : f.total }),
|
|
1963
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: x(w.net) }),
|
|
1964
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: x(w.vat) }),
|
|
1965
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: x(w.gross) })
|
|
1946
1966
|
] }) })
|
|
1947
1967
|
]
|
|
1948
1968
|
}
|
|
1949
1969
|
);
|
|
1950
1970
|
}
|
|
1951
|
-
),
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
/* @__PURE__ */
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
}
|
|
2024
|
-
), Ht = [
|
|
1971
|
+
), Gt = [], _r = /* @__PURE__ */ se(function(e, r) {
|
|
1972
|
+
const { t: n } = oe(), {
|
|
1973
|
+
methods: a = Gt,
|
|
1974
|
+
value: i,
|
|
1975
|
+
onChange: d,
|
|
1976
|
+
layout: s = "list",
|
|
1977
|
+
columns: o = 2,
|
|
1978
|
+
currency: l,
|
|
1979
|
+
label: y,
|
|
1980
|
+
name: N,
|
|
1981
|
+
readOnly: b = !1,
|
|
1982
|
+
className: u,
|
|
1983
|
+
style: f,
|
|
1984
|
+
id: h,
|
|
1985
|
+
accessMode: w,
|
|
1986
|
+
"data-testid": x
|
|
1987
|
+
} = e, m = _e(), g = N ?? `nice-pm-${m}`, v = K(() => {
|
|
1988
|
+
if (!l)
|
|
1989
|
+
return a;
|
|
1990
|
+
const M = l.toUpperCase();
|
|
1991
|
+
return a.filter(
|
|
1992
|
+
(q) => !q.currencies || q.currencies.map((I) => I.toUpperCase()).includes(M)
|
|
1993
|
+
);
|
|
1994
|
+
}, [a, l]);
|
|
1995
|
+
if (w === "hidden")
|
|
1996
|
+
return null;
|
|
1997
|
+
const S = b || w === "disabled" || w === "readOnly", A = `nice-payment-method-selector nice-payment-method-selector--${s}` + (u ? ` ${u}` : ""), P = s === "grid" ? { gridTemplateColumns: `repeat(${o}, minmax(0, 1fr))` } : void 0;
|
|
1998
|
+
return /* @__PURE__ */ _("div", { ref: r, id: h, className: A, style: f, "data-testid": x, children: [
|
|
1999
|
+
y && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__label", children: y }),
|
|
2000
|
+
/* @__PURE__ */ _(
|
|
2001
|
+
"div",
|
|
2002
|
+
{
|
|
2003
|
+
className: "nice-payment-method-selector__options",
|
|
2004
|
+
style: P,
|
|
2005
|
+
role: "radiogroup",
|
|
2006
|
+
"aria-label": y ?? n("paymentMethodSelector.paymentMethod", "Payment method"),
|
|
2007
|
+
children: [
|
|
2008
|
+
v.map((M) => {
|
|
2009
|
+
const q = M.id === i, I = S || M.disabled;
|
|
2010
|
+
return /* @__PURE__ */ _(
|
|
2011
|
+
"label",
|
|
2012
|
+
{
|
|
2013
|
+
className: "nice-payment-method-selector__option" + (q ? " nice-payment-method-selector__option--selected" : "") + (I ? " nice-payment-method-selector__option--disabled" : ""),
|
|
2014
|
+
children: [
|
|
2015
|
+
/* @__PURE__ */ c(
|
|
2016
|
+
"input",
|
|
2017
|
+
{
|
|
2018
|
+
type: "radio",
|
|
2019
|
+
className: "nice-payment-method-selector__radio",
|
|
2020
|
+
name: g,
|
|
2021
|
+
value: M.id,
|
|
2022
|
+
checked: q,
|
|
2023
|
+
disabled: I,
|
|
2024
|
+
onChange: () => d == null ? void 0 : d(M.id)
|
|
2025
|
+
}
|
|
2026
|
+
),
|
|
2027
|
+
M.icon && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__icon", children: M.icon }),
|
|
2028
|
+
/* @__PURE__ */ _("span", { className: "nice-payment-method-selector__text", children: [
|
|
2029
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-method-selector__name", children: M.label }),
|
|
2030
|
+
M.description && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__desc", children: M.description })
|
|
2031
|
+
] })
|
|
2032
|
+
]
|
|
2033
|
+
},
|
|
2034
|
+
M.id
|
|
2035
|
+
);
|
|
2036
|
+
}),
|
|
2037
|
+
v.length === 0 && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__empty", children: n("paymentMethodSelector.noMethodsAvailable", "No methods available.") })
|
|
2038
|
+
]
|
|
2039
|
+
}
|
|
2040
|
+
)
|
|
2041
|
+
] });
|
|
2042
|
+
}), Zt = [
|
|
2025
2043
|
{
|
|
2026
2044
|
target: ".nice-payment-provider-config",
|
|
2027
2045
|
titleKey: "tutorial.paymentProviderConfig.intro.title",
|
|
@@ -2030,258 +2048,264 @@ const pr = ie(
|
|
|
2030
2048
|
content: "Pick a provider, fill its credentials (secrets are masked), choose test/live, enable methods and copy the webhook URL.",
|
|
2031
2049
|
placement: "auto"
|
|
2032
2050
|
}
|
|
2033
|
-
],
|
|
2051
|
+
], Jt = {
|
|
2034
2052
|
providerId: "",
|
|
2035
2053
|
mode: "test",
|
|
2036
2054
|
credentials: {},
|
|
2037
2055
|
enabledMethods: []
|
|
2038
|
-
},
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
M(!1);
|
|
2086
|
-
}
|
|
2056
|
+
}, gr = /* @__PURE__ */ se(function(e, r) {
|
|
2057
|
+
const { t: n } = oe(), {
|
|
2058
|
+
value: a,
|
|
2059
|
+
defaultValue: i,
|
|
2060
|
+
onChange: d,
|
|
2061
|
+
providers: s,
|
|
2062
|
+
onTestConnection: o,
|
|
2063
|
+
showWebhookUrl: l = !0,
|
|
2064
|
+
baseUrl: y,
|
|
2065
|
+
readOnly: N = !1,
|
|
2066
|
+
testLabel: b = n("paymentProviderConfig.testConnection", "Test connection"),
|
|
2067
|
+
tutorial: u,
|
|
2068
|
+
className: f,
|
|
2069
|
+
style: h,
|
|
2070
|
+
id: w,
|
|
2071
|
+
accessMode: x,
|
|
2072
|
+
"data-testid": m
|
|
2073
|
+
} = e, [g, v] = Me({
|
|
2074
|
+
value: a,
|
|
2075
|
+
defaultValue: i,
|
|
2076
|
+
fallbackValue: Jt,
|
|
2077
|
+
onChange: d,
|
|
2078
|
+
componentName: "NicePaymentProviderConfig"
|
|
2079
|
+
}), S = _e(), [A, P] = H(/* @__PURE__ */ new Set()), [M, q] = H(!1), [I, W] = H(null), B = K(() => s ? s.map((p) => we[p]).filter((p) => !!p) : Ot, [s]), D = we[g.providerId];
|
|
2080
|
+
if (x === "hidden")
|
|
2081
|
+
return null;
|
|
2082
|
+
const T = N || x === "disabled" || x === "readOnly", O = (p) => {
|
|
2083
|
+
W(null), P(/* @__PURE__ */ new Set()), v({ providerId: p, mode: g.mode, credentials: {}, enabledMethods: [] });
|
|
2084
|
+
}, X = (p, F) => {
|
|
2085
|
+
v({ ...g, credentials: { ...g.credentials, [p]: F } });
|
|
2086
|
+
}, ne = (p) => {
|
|
2087
|
+
const F = new Set(g.enabledMethods ?? []);
|
|
2088
|
+
F.has(p) ? F.delete(p) : F.add(p), v({ ...g, enabledMethods: [...F] });
|
|
2089
|
+
}, Y = (p) => {
|
|
2090
|
+
P((F) => {
|
|
2091
|
+
const z = new Set(F);
|
|
2092
|
+
return z.has(p) ? z.delete(p) : z.add(p), z;
|
|
2093
|
+
});
|
|
2094
|
+
}, Z = async () => {
|
|
2095
|
+
if (o) {
|
|
2096
|
+
q(!0), W(null);
|
|
2097
|
+
try {
|
|
2098
|
+
W(await o(g));
|
|
2099
|
+
} catch (p) {
|
|
2100
|
+
W({ ok: !1, message: p instanceof Error ? p.message : String(p) });
|
|
2101
|
+
} finally {
|
|
2102
|
+
q(!1);
|
|
2087
2103
|
}
|
|
2088
|
-
}
|
|
2089
|
-
|
|
2090
|
-
)
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
(k == null ? void 0 : k.hasTestMode) && /* @__PURE__ */ h("div", { className: "nice-payment-provider-config__mode", role: "group", "aria-label": "Mode", children: [
|
|
2111
|
-
/* @__PURE__ */ c(
|
|
2112
|
-
"button",
|
|
2113
|
-
{
|
|
2114
|
-
type: "button",
|
|
2115
|
-
className: "nice-payment-provider-config__mode-btn" + (w.mode === "test" ? " nice-payment-provider-config__mode-btn--active" : ""),
|
|
2116
|
-
onClick: () => N({ ...w, mode: "test" }),
|
|
2117
|
-
disabled: F,
|
|
2118
|
-
children: "Test"
|
|
2119
|
-
}
|
|
2120
|
-
),
|
|
2121
|
-
/* @__PURE__ */ c(
|
|
2122
|
-
"button",
|
|
2123
|
-
{
|
|
2124
|
-
type: "button",
|
|
2125
|
-
className: "nice-payment-provider-config__mode-btn" + (w.mode === "live" ? " nice-payment-provider-config__mode-btn--active" : ""),
|
|
2126
|
-
onClick: () => N({ ...w, mode: "live" }),
|
|
2127
|
-
disabled: F,
|
|
2128
|
-
children: "Live"
|
|
2129
|
-
}
|
|
2130
|
-
)
|
|
2131
|
-
] })
|
|
2104
|
+
}
|
|
2105
|
+
}, Q = D != null && D.webhookPath ? `${(y ?? "").replace(/\/$/, "")}${D.webhookPath}` : "", ae = (D == null ? void 0 : D.supportedCurrencies) === "*" ? n("paymentProviderConfig.allCurrencies", "All currencies") : ((D == null ? void 0 : D.supportedCurrencies) ?? []).join(", "), E = "nice-payment-provider-config" + (f ? ` ${f}` : ""), k = ((D == null ? void 0 : D.credentials) ?? []).filter(
|
|
2106
|
+
(p) => !p.testOnly || g.mode === "test"
|
|
2107
|
+
);
|
|
2108
|
+
return /* @__PURE__ */ _("div", { ref: r, id: w, className: E, style: h, "data-testid": m, children: [
|
|
2109
|
+
u && /* @__PURE__ */ c("div", { className: "nice-payment-provider-config__tutorial", children: /* @__PURE__ */ c(st, { steps: ot(u, Zt) }) }),
|
|
2110
|
+
/* @__PURE__ */ _("div", { className: "nice-payment-provider-config__row", children: [
|
|
2111
|
+
/* @__PURE__ */ _("label", { className: "nice-payment-provider-config__field", children: [
|
|
2112
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: n("paymentProviderConfig.provider", "Provider") }),
|
|
2113
|
+
/* @__PURE__ */ _(
|
|
2114
|
+
"select",
|
|
2115
|
+
{
|
|
2116
|
+
className: "nice-payment-provider-config__select",
|
|
2117
|
+
value: g.providerId,
|
|
2118
|
+
disabled: T,
|
|
2119
|
+
onChange: (p) => O(p.target.value),
|
|
2120
|
+
children: [
|
|
2121
|
+
/* @__PURE__ */ c("option", { value: "", children: n("paymentProviderConfig.selectProvider", "— select provider —") }),
|
|
2122
|
+
B.map((p) => /* @__PURE__ */ c("option", { value: p.id, children: p.name }, p.id))
|
|
2123
|
+
]
|
|
2124
|
+
}
|
|
2125
|
+
)
|
|
2132
2126
|
] }),
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
"
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2127
|
+
(D == null ? void 0 : D.hasTestMode) && /* @__PURE__ */ _(
|
|
2128
|
+
"div",
|
|
2129
|
+
{
|
|
2130
|
+
className: "nice-payment-provider-config__mode",
|
|
2131
|
+
role: "group",
|
|
2132
|
+
"aria-label": n("paymentProviderConfig.mode", "Mode"),
|
|
2133
|
+
children: [
|
|
2134
|
+
/* @__PURE__ */ c(
|
|
2135
|
+
"button",
|
|
2136
|
+
{
|
|
2137
|
+
type: "button",
|
|
2138
|
+
className: "nice-payment-provider-config__mode-btn" + (g.mode === "test" ? " nice-payment-provider-config__mode-btn--active" : ""),
|
|
2139
|
+
onClick: () => v({ ...g, mode: "test" }),
|
|
2140
|
+
disabled: T,
|
|
2141
|
+
children: n("paymentProviderConfig.test", "Test")
|
|
2142
|
+
}
|
|
2143
|
+
),
|
|
2144
|
+
/* @__PURE__ */ c(
|
|
2145
|
+
"button",
|
|
2146
|
+
{
|
|
2147
|
+
type: "button",
|
|
2148
|
+
className: "nice-payment-provider-config__mode-btn" + (g.mode === "live" ? " nice-payment-provider-config__mode-btn--active" : ""),
|
|
2149
|
+
onClick: () => v({ ...g, mode: "live" }),
|
|
2150
|
+
disabled: T,
|
|
2151
|
+
children: n("paymentProviderConfig.live", "Live")
|
|
2152
|
+
}
|
|
2153
|
+
)
|
|
2154
|
+
]
|
|
2155
|
+
}
|
|
2156
|
+
)
|
|
2157
|
+
] }),
|
|
2158
|
+
D && /* @__PURE__ */ _(it, { children: [
|
|
2159
|
+
/* @__PURE__ */ _("div", { className: "nice-payment-provider-config__meta", children: [
|
|
2160
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__badge", children: D.type }),
|
|
2161
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__currencies", children: ae })
|
|
2162
|
+
] }),
|
|
2163
|
+
/* @__PURE__ */ c("div", { className: "nice-payment-provider-config__credentials", children: k.map((p) => {
|
|
2164
|
+
const F = `${S}-${p.key}`, z = p.secret, C = A.has(p.key);
|
|
2165
|
+
return /* @__PURE__ */ _("div", { className: "nice-payment-provider-config__field", children: [
|
|
2166
|
+
/* @__PURE__ */ _("label", { className: "nice-payment-provider-config__field-label", htmlFor: F, children: [
|
|
2167
|
+
p.label,
|
|
2168
|
+
p.required && /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__required", children: " *" })
|
|
2169
|
+
] }),
|
|
2170
|
+
/* @__PURE__ */ _("div", { className: "nice-payment-provider-config__input-wrap", children: [
|
|
2176
2171
|
/* @__PURE__ */ c(
|
|
2177
2172
|
"input",
|
|
2178
2173
|
{
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2174
|
+
id: F,
|
|
2175
|
+
type: z && !C ? "password" : "text",
|
|
2176
|
+
className: "nice-payment-provider-config__input",
|
|
2177
|
+
value: g.credentials[p.key] ?? "",
|
|
2178
|
+
readOnly: T,
|
|
2179
|
+
autoComplete: z ? "new-password" : "off",
|
|
2180
|
+
onChange: (L) => X(p.key, L.target.value)
|
|
2183
2181
|
}
|
|
2184
2182
|
),
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2183
|
+
z && /* @__PURE__ */ c(
|
|
2184
|
+
"button",
|
|
2185
|
+
{
|
|
2186
|
+
type: "button",
|
|
2187
|
+
className: "nice-payment-provider-config__reveal",
|
|
2188
|
+
onClick: () => Y(p.key),
|
|
2189
|
+
"aria-label": C ? n("paymentProviderConfig.hide", "Hide") : n("paymentProviderConfig.reveal", "Reveal"),
|
|
2190
|
+
"aria-pressed": C,
|
|
2191
|
+
children: /* @__PURE__ */ c(Pe, { name: C ? "eye-off" : "eye", size: 14 })
|
|
2192
|
+
}
|
|
2193
|
+
)
|
|
2194
|
+
] }),
|
|
2195
|
+
p.help && /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__help", children: p.help })
|
|
2196
|
+
] }, p.key);
|
|
2197
|
+
}) }),
|
|
2198
|
+
D.supportedMethods && D.supportedMethods.length > 0 && /* @__PURE__ */ _("div", { className: "nice-payment-provider-config__methods", children: [
|
|
2199
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: n("paymentProviderConfig.enabledMethods", "Enabled methods") }),
|
|
2200
|
+
/* @__PURE__ */ c("div", { className: "nice-payment-provider-config__method-list", children: D.supportedMethods.map((p) => /* @__PURE__ */ _("label", { className: "nice-payment-provider-config__method", children: [
|
|
2193
2201
|
/* @__PURE__ */ c(
|
|
2194
|
-
"
|
|
2202
|
+
"input",
|
|
2195
2203
|
{
|
|
2196
|
-
type: "
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
children: I ? "Testing…" : v
|
|
2204
|
+
type: "checkbox",
|
|
2205
|
+
checked: (g.enabledMethods ?? []).includes(p),
|
|
2206
|
+
disabled: T,
|
|
2207
|
+
onChange: () => ne(p)
|
|
2201
2208
|
}
|
|
2202
2209
|
),
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2210
|
+
p
|
|
2211
|
+
] }, p)) })
|
|
2212
|
+
] }),
|
|
2213
|
+
l && D.webhookPath && /* @__PURE__ */ _("div", { className: "nice-payment-provider-config__field", children: [
|
|
2214
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: n("paymentProviderConfig.webhookUrl", "Webhook URL") }),
|
|
2215
|
+
/* @__PURE__ */ c("code", { className: "nice-payment-provider-config__webhook", children: Q })
|
|
2216
|
+
] }),
|
|
2217
|
+
o && /* @__PURE__ */ _("div", { className: "nice-payment-provider-config__test", children: [
|
|
2218
|
+
/* @__PURE__ */ c(
|
|
2219
|
+
"button",
|
|
2220
|
+
{
|
|
2221
|
+
type: "button",
|
|
2222
|
+
className: "nice-payment-provider-config__test-btn",
|
|
2223
|
+
onClick: () => void Z(),
|
|
2224
|
+
disabled: T || M,
|
|
2225
|
+
children: M ? n("paymentProviderConfig.testing", "Testing…") : b
|
|
2226
|
+
}
|
|
2227
|
+
),
|
|
2228
|
+
I && /* @__PURE__ */ _(
|
|
2229
|
+
"span",
|
|
2230
|
+
{
|
|
2231
|
+
className: "nice-payment-provider-config__test-result nice-payment-provider-config__test-result--" + (I.ok ? "ok" : "error"),
|
|
2232
|
+
children: [
|
|
2233
|
+
/* @__PURE__ */ c(Pe, { name: I.ok ? "check" : "close", size: 14 }),
|
|
2234
|
+
" ",
|
|
2235
|
+
I.message ?? (I.ok ? n("paymentProviderConfig.ok", "OK") : n("paymentProviderConfig.failed", "Failed"))
|
|
2236
|
+
]
|
|
2237
|
+
}
|
|
2238
|
+
)
|
|
2215
2239
|
] })
|
|
2216
|
-
] })
|
|
2217
|
-
}
|
|
2218
|
-
);
|
|
2240
|
+
] })
|
|
2241
|
+
] });
|
|
2242
|
+
});
|
|
2219
2243
|
export {
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2244
|
+
ft as EcbRatesProvider,
|
|
2245
|
+
ht as ExchangeRateHostProvider,
|
|
2246
|
+
pt as FrankfurterProvider,
|
|
2247
|
+
_t as FreeForexApiProvider,
|
|
2248
|
+
vt as MockPaymentProcessor,
|
|
2249
|
+
fe as NICE_CURRENCY_CATALOG,
|
|
2250
|
+
pr as NICE_CURRENCY_CODES,
|
|
2251
|
+
Tt as NICE_PAYMENT_PROCESSORS,
|
|
2252
|
+
Ot as NICE_PAYMENT_PROVIDER_LIST,
|
|
2253
|
+
we as NICE_PAYMENT_PROVIDER_PROFILES,
|
|
2254
|
+
bt as NbpRatesProvider,
|
|
2255
|
+
Lt as NiceCreditCardInput,
|
|
2256
|
+
br as NiceCurrencyConverter,
|
|
2257
|
+
Ge as NiceCurrencySelector,
|
|
2258
|
+
Oe as NiceMoney,
|
|
2259
|
+
Ze as NiceMoneyInput,
|
|
2260
|
+
yr as NicePaymentForm,
|
|
2261
|
+
_r as NicePaymentMethodSelector,
|
|
2262
|
+
gr as NicePaymentProviderConfig,
|
|
2263
|
+
hr as NicePriceTag,
|
|
2264
|
+
fr as NiceTaxBreakdown,
|
|
2265
|
+
yt as OpenExchangeRatesProvider,
|
|
2266
|
+
ir as StaticExchangeRateProvider,
|
|
2267
|
+
ye as addMoney,
|
|
2268
|
+
tr as compareMoney,
|
|
2269
|
+
gt as convertMoney,
|
|
2270
|
+
or as createEcbRatesProvider,
|
|
2271
|
+
dr as createFreeForexApiProvider,
|
|
2272
|
+
sr as createNbpRatesProvider,
|
|
2273
|
+
lr as createOpenExchangeRatesProvider,
|
|
2274
|
+
ke as detectCardBrand,
|
|
2275
|
+
be as expectedCvcLength,
|
|
2276
|
+
re as findCurrency,
|
|
2277
|
+
ur as findPaymentProviderProfile,
|
|
2278
|
+
mt as formatCardNumber,
|
|
2279
|
+
ie as formatMoney,
|
|
2280
|
+
He as fromMoney,
|
|
2281
|
+
Ye as isExpiryValid,
|
|
2282
|
+
nr as isNegative,
|
|
2283
|
+
rr as isZero,
|
|
2284
|
+
ze as luhnCheck,
|
|
2285
|
+
kt as makeAdyenAdapter,
|
|
2286
|
+
xt as makeAutopayAdapter,
|
|
2287
|
+
Rt as makeBlikAdapter,
|
|
2288
|
+
Pt as makeBraintreeAdapter,
|
|
2289
|
+
At as makeCoinbaseCommerceAdapter,
|
|
2290
|
+
Ut as makeKlarnaAdapter,
|
|
2291
|
+
Dt as makeMollieAdapter,
|
|
2292
|
+
wt as makePayPalAdapter,
|
|
2293
|
+
St as makePayUAdapter,
|
|
2294
|
+
It as makePrzelewy24Adapter,
|
|
2295
|
+
Mt as makeRazorpayAdapter,
|
|
2296
|
+
Ct as makeSquareAdapter,
|
|
2297
|
+
Nt as makeStripeAdapter,
|
|
2298
|
+
$t as makeTpayAdapter,
|
|
2299
|
+
cr as maskCardNumber,
|
|
2300
|
+
Se as multiplyMoney,
|
|
2301
|
+
ar as negateMoney,
|
|
2302
|
+
je as normaliseExpiry,
|
|
2303
|
+
ut as parseMoney,
|
|
2304
|
+
er as registerCurrency,
|
|
2305
|
+
dt as subtractMoney,
|
|
2306
|
+
ce as toMoney,
|
|
2307
|
+
Ie as useNiceExchangeRate,
|
|
2308
|
+
mr as useNiceMoney,
|
|
2285
2309
|
Kt as useNicePayment,
|
|
2286
|
-
|
|
2310
|
+
qe as validateCreditCard
|
|
2287
2311
|
};
|