@nice2dev/ui-money 1.1.10 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +173 -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 +1300 -1288
- 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
|
|
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 Z = (t, e, r) => rt(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import nt, { useState as z, useRef as at, useEffect as ct, useMemo as K, useCallback as Y, forwardRef as se, useId as _e } from "react";
|
|
5
|
+
import { jsxs as b, jsx as c, Fragment as it } from "react/jsx-runtime";
|
|
6
|
+
import { useNiceTranslation as pe, NiceIcon as Me, useControllableState as Pe, 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,186 +226,186 @@ 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 ne(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 ae(t, e) {
|
|
239
|
+
const r = ne(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 = ne(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 Ie(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 = ne(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) ? ae(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
|
+
Z(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
|
-
|
|
399
|
-
|
|
400
|
-
|
|
398
|
+
Z(this, "cache", /* @__PURE__ */ new Map());
|
|
399
|
+
Z(this, "fetchImpl");
|
|
400
|
+
Z(this, "ttl");
|
|
401
401
|
this.fetchImpl = e.fetchImpl ?? fetch, this.ttl = e.cacheTtl ?? 6e4;
|
|
402
402
|
}
|
|
403
403
|
cacheKey(e, r) {
|
|
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,141 +414,141 @@ 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
|
+
Z(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 v = { base:
|
|
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 v = { base: a, quote: i, rate: y, asOf: l.date };
|
|
436
436
|
return this.setCached(v), v;
|
|
437
437
|
}
|
|
438
438
|
}
|
|
439
|
-
class
|
|
440
|
-
constructor(r,
|
|
441
|
-
super(
|
|
442
|
-
|
|
439
|
+
class yt extends Ce {
|
|
440
|
+
constructor(r, n = {}) {
|
|
441
|
+
super(n);
|
|
442
|
+
Z(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], v = l.rates[i];
|
|
456
|
+
if (y == null || v == null)
|
|
457
|
+
throw new Error(`OpenExchangeRates: missing rate for ${a} or ${i}`);
|
|
458
|
+
const f = {
|
|
459
|
+
base: a,
|
|
460
460
|
quote: i,
|
|
461
|
-
rate: v /
|
|
461
|
+
rate: v / y,
|
|
462
462
|
asOf: new Date(l.timestamp * 1e3).toISOString()
|
|
463
463
|
};
|
|
464
|
-
return this.setCached(
|
|
464
|
+
return this.setCached(f), f;
|
|
465
465
|
}
|
|
466
466
|
}
|
|
467
|
-
class
|
|
467
|
+
class ht extends Ce {
|
|
468
468
|
constructor(r = {}) {
|
|
469
469
|
super(r);
|
|
470
|
-
|
|
470
|
+
Z(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 f;
|
|
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(),
|
|
483
|
+
const l = await o.json(), y = ((f = l.info) == null ? void 0 : f.rate) ?? l.result, v = { base: a, quote: i, rate: y, asOf: l.date };
|
|
484
484
|
return this.setCached(v), v;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
class
|
|
487
|
+
class bt extends Ce {
|
|
488
488
|
constructor(r = {}) {
|
|
489
489
|
super(r);
|
|
490
|
-
|
|
491
|
-
|
|
490
|
+
Z(this, "id", "nbp");
|
|
491
|
+
Z(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
|
|
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
501
|
const s = async (v) => {
|
|
502
|
-
var
|
|
502
|
+
var N;
|
|
503
503
|
if (v === "PLN")
|
|
504
504
|
return { rate: 1, date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) };
|
|
505
|
-
const
|
|
506
|
-
if (!
|
|
505
|
+
const f = `https://api.nbp.pl/api/exchangerates/rates/${this.table}/${v}/?format=json`, u = await this.fetchImpl(f);
|
|
506
|
+
if (!u.ok)
|
|
507
507
|
return null;
|
|
508
|
-
const
|
|
509
|
-
return
|
|
510
|
-
}, o = await s(
|
|
508
|
+
const g = (N = (await u.json()).rates) == null ? void 0 : N[0];
|
|
509
|
+
return g ? { rate: g.mid ?? g.ask ?? 0, date: g.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
|
+
Z(this, "id", "ecb");
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
class
|
|
528
|
+
class _t extends ht {
|
|
529
529
|
constructor() {
|
|
530
530
|
super(...arguments);
|
|
531
|
-
|
|
531
|
+
Z(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 = ne(t.currency), i = ne(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
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
547
|
+
Z(this, "id");
|
|
548
|
+
Z(this, "name");
|
|
549
|
+
Z(this, "supportedCurrencies");
|
|
550
|
+
Z(this, "minimums");
|
|
551
|
+
Z(this, "counter", 0);
|
|
552
552
|
this.id = e.id ?? "mock", this.name = e.name ?? "Mock Processor", this.supportedCurrencies = e.supportedCurrencies ?? "*";
|
|
553
553
|
}
|
|
554
554
|
newId(e) {
|
|
@@ -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 Mt(t) {
|
|
662
662
|
return V("braintree", "Braintree", "*", t);
|
|
663
663
|
}
|
|
664
|
-
function
|
|
664
|
+
function Pt(t) {
|
|
665
665
|
return V("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function It(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 St(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 Et = {
|
|
705
|
+
mock: () => new vt(),
|
|
706
|
+
stripe: () => Nt(),
|
|
707
|
+
paypal: () => wt(),
|
|
708
|
+
adyen: () => kt(),
|
|
709
|
+
square: () => Ct(),
|
|
710
|
+
mollie: () => Dt(),
|
|
711
|
+
braintree: () => Mt(),
|
|
712
|
+
razorpay: () => Pt(),
|
|
713
|
+
payu: () => It(),
|
|
714
|
+
przelewy24: () => St(),
|
|
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 Tt(t) {
|
|
722
|
+
const e = Et[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,408 @@ 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: Tt(e ?? t.id),
|
|
944
|
+
webhookPath: Ft(t.id)
|
|
945
945
|
};
|
|
946
|
-
return [t.id,
|
|
946
|
+
return [t.id, n];
|
|
947
947
|
})
|
|
948
|
-
),
|
|
949
|
-
|
|
948
|
+
), Kt = /* @__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 : ae(
|
|
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] = z(r), i = Y(
|
|
963
|
+
(f) => a((u) => ae(f, u.currency)),
|
|
964
964
|
[]
|
|
965
|
-
),
|
|
966
|
-
|
|
967
|
-
}, []), s =
|
|
968
|
-
(
|
|
965
|
+
), d = Y((f) => {
|
|
966
|
+
a((u) => ({ ...u, currency: f.toUpperCase() }));
|
|
967
|
+
}, []), s = Y((f) => a((u) => ye(u, f)), []), o = Y(
|
|
968
|
+
(f) => a((u) => dt(u, f)),
|
|
969
969
|
[]
|
|
970
|
-
), l =
|
|
971
|
-
(
|
|
970
|
+
), l = Y(
|
|
971
|
+
(f) => a((u) => Ie(u, f)),
|
|
972
972
|
[]
|
|
973
|
-
),
|
|
974
|
-
return { money:
|
|
973
|
+
), y = K(() => ie(n, { locale: e }), [n, e]), v = K(() => He(n), [n]);
|
|
974
|
+
return { money: n, setMoney: a, setMajor: i, setCurrency: d, add: s, subtract: o, scale: l, formatted: y, major: v };
|
|
975
975
|
}
|
|
976
|
-
function
|
|
977
|
-
const [
|
|
978
|
-
return
|
|
976
|
+
function Se(t, e, r) {
|
|
977
|
+
const [n, a] = z(null), [i, d] = z(null), [s, o] = z(!1), l = at(0);
|
|
978
|
+
return ct(() => {
|
|
979
979
|
if (!t) {
|
|
980
|
-
|
|
980
|
+
a(null);
|
|
981
981
|
return;
|
|
982
982
|
}
|
|
983
|
-
const
|
|
984
|
-
o(!0),
|
|
985
|
-
l.current ===
|
|
983
|
+
const y = ++l.current;
|
|
984
|
+
o(!0), d(null), gt(t, e, r).then((v) => {
|
|
985
|
+
l.current === y && a(v);
|
|
986
986
|
}).catch((v) => {
|
|
987
|
-
l.current ===
|
|
987
|
+
l.current === y && (d(v instanceof Error ? v : new Error(String(v))), a(null));
|
|
988
988
|
}).finally(() => {
|
|
989
|
-
l.current ===
|
|
989
|
+
l.current === y && o(!1);
|
|
990
990
|
});
|
|
991
|
-
}, [t == null ? void 0 : t.amount, t == null ? void 0 : t.currency, e, r]), { converted:
|
|
991
|
+
}, [t == null ? void 0 : t.amount, t == null ? void 0 : t.currency, e, r]), { converted: n, loading: s, error: i };
|
|
992
992
|
}
|
|
993
|
-
function
|
|
994
|
-
const [e, r] = z("idle"), [
|
|
995
|
-
r("idle"),
|
|
996
|
-
}, []), o =
|
|
997
|
-
async (
|
|
998
|
-
r("authorizing"),
|
|
993
|
+
function Ot(t) {
|
|
994
|
+
const [e, r] = z("idle"), [n, a] = z(null), [i, d] = z(null), s = Y(() => {
|
|
995
|
+
r("idle"), a(null), d(null);
|
|
996
|
+
}, []), o = Y(
|
|
997
|
+
async (f) => {
|
|
998
|
+
r("authorizing"), d(null);
|
|
999
999
|
try {
|
|
1000
|
-
const
|
|
1001
|
-
return
|
|
1002
|
-
} catch (
|
|
1003
|
-
const
|
|
1004
|
-
throw
|
|
1000
|
+
const u = await t.authorize(f);
|
|
1001
|
+
return a(u), r(u.status), u;
|
|
1002
|
+
} catch (u) {
|
|
1003
|
+
const m = u instanceof Error ? u : new Error(String(u));
|
|
1004
|
+
throw d(m), r("failed"), m;
|
|
1005
1005
|
}
|
|
1006
1006
|
},
|
|
1007
1007
|
[t]
|
|
1008
|
-
), l =
|
|
1009
|
-
async (
|
|
1010
|
-
const
|
|
1011
|
-
if (!
|
|
1008
|
+
), l = Y(
|
|
1009
|
+
async (f, u) => {
|
|
1010
|
+
const m = f ?? (n == null ? void 0 : n.id);
|
|
1011
|
+
if (!m)
|
|
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 g = await t.capture(m, u);
|
|
1016
|
+
return a(g), r(g.status), g;
|
|
1017
|
+
} catch (g) {
|
|
1018
|
+
const N = g instanceof Error ? g : new Error(String(g));
|
|
1019
|
+
throw d(N), r("failed"), N;
|
|
1020
1020
|
}
|
|
1021
1021
|
},
|
|
1022
|
-
[t,
|
|
1023
|
-
),
|
|
1024
|
-
async (
|
|
1025
|
-
const
|
|
1026
|
-
if (!
|
|
1022
|
+
[t, n == null ? void 0 : n.id]
|
|
1023
|
+
), y = Y(
|
|
1024
|
+
async (f) => {
|
|
1025
|
+
const u = f ?? (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 m = await t.cancel(u);
|
|
1029
|
+
return a(m), r(m.status), m;
|
|
1030
1030
|
},
|
|
1031
|
-
[t,
|
|
1032
|
-
), v =
|
|
1033
|
-
async (
|
|
1034
|
-
const
|
|
1035
|
-
if (!
|
|
1031
|
+
[t, n == null ? void 0 : n.id]
|
|
1032
|
+
), v = Y(
|
|
1033
|
+
async (f, u) => {
|
|
1034
|
+
const m = f ?? (n == null ? void 0 : n.id);
|
|
1035
|
+
if (!m)
|
|
1036
1036
|
throw new Error("No payment id to refund");
|
|
1037
|
-
const
|
|
1038
|
-
return
|
|
1037
|
+
const g = await t.refund(m, u);
|
|
1038
|
+
return a(g), r(g.status), g;
|
|
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: v, 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 Ke = /* @__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
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
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: v,
|
|
1057
|
+
"aria-label": f
|
|
1058
|
+
}, u) {
|
|
1059
|
+
const m = K(() => {
|
|
1060
|
+
if (e)
|
|
1061
|
+
return e;
|
|
1062
|
+
if (r != null && n) {
|
|
1063
|
+
const _ = ne(n), w = (_ == null ? void 0 : _.decimals) ?? 2;
|
|
1064
|
+
return {
|
|
1065
|
+
amount: Math.round(r * Math.pow(10, w)),
|
|
1066
|
+
currency: n.toUpperCase()
|
|
1067
|
+
};
|
|
1068
|
+
}
|
|
1069
|
+
return null;
|
|
1070
|
+
}, [e, r, n]), g = K(() => m ? m.amount === 0 && s != null ? s : ie(m, { locale: a, currencyDisplay: i }) : "", [m, a, i, s]), { converted: N } = Se(
|
|
1071
|
+
o && l ? m : null,
|
|
1072
|
+
o ?? "",
|
|
1073
|
+
l
|
|
1074
|
+
);
|
|
1075
|
+
if (!m)
|
|
1076
|
+
return null;
|
|
1077
|
+
const p = m.amount < 0, D = "nice-money" + (d && p ? " nice-money--negative" : "") + (y ? ` ${y}` : "");
|
|
1078
|
+
return /* @__PURE__ */ b("span", { ref: u, className: D, style: v, "aria-label": f, children: [
|
|
1079
|
+
/* @__PURE__ */ c("span", { className: "nice-money__value", children: g }),
|
|
1080
|
+
N && /* @__PURE__ */ b("span", { className: "nice-money__converted", "aria-label": `Converted to ${N.currency}`, children: [
|
|
1081
|
+
" ≈ ",
|
|
1082
|
+
ie(N, { locale: a })
|
|
1083
|
+
] })
|
|
1084
|
+
] });
|
|
1085
|
+
}
|
|
1086
|
+
), pr = fe.map((t) => t.code).sort(), Ge = /* @__PURE__ */ se(function({
|
|
1087
|
+
value: e,
|
|
1088
|
+
onChange: r,
|
|
1089
|
+
options: n = fe,
|
|
1090
|
+
recents: a = [],
|
|
1091
|
+
searchable: i,
|
|
1092
|
+
showCode: d = !0,
|
|
1093
|
+
showSymbol: s = !0,
|
|
1094
|
+
compact: o = !1,
|
|
1095
|
+
disabled: l,
|
|
1096
|
+
readOnly: y,
|
|
1097
|
+
loading: v,
|
|
1098
|
+
accessMode: f,
|
|
1099
|
+
label: u,
|
|
1100
|
+
helperText: m,
|
|
1101
|
+
error: g,
|
|
1102
|
+
required: N,
|
|
1103
|
+
size: p = "md",
|
|
1104
|
+
labelPlacement: D = "top",
|
|
1105
|
+
labelWidth: _,
|
|
1106
|
+
controlWidth: w,
|
|
1107
|
+
className: U,
|
|
1108
|
+
style: G,
|
|
1109
|
+
id: M,
|
|
1110
|
+
name: S,
|
|
1111
|
+
title: $,
|
|
1112
|
+
"data-testid": A,
|
|
1113
|
+
"aria-label": W,
|
|
1114
|
+
placeholder: O
|
|
1115
|
+
}, k) {
|
|
1116
|
+
const { t: B } = pe(), F = f === "hidden", Q = l || f === "disabled" || v, ce = y || f === "readOnly", H = _e(), te = M ?? `nice-cs-${H}`, [J, T] = z(""), E = i ?? n.length > 8, P = K(() => {
|
|
1117
|
+
if (!J.trim())
|
|
1118
|
+
return n;
|
|
1119
|
+
const I = J.trim().toLowerCase();
|
|
1120
|
+
return n.filter(
|
|
1121
|
+
(x) => x.code.toLowerCase().includes(I) || x.name.toLowerCase().includes(I) || x.symbol.toLowerCase().includes(I)
|
|
1122
|
+
);
|
|
1123
|
+
}, [n, J]), h = K(() => {
|
|
1124
|
+
const I = /* @__PURE__ */ new Set();
|
|
1125
|
+
return a.map((x) => ne(x)).filter((x) => !!x && !I.has(x.code) && !!I.add(x.code));
|
|
1126
|
+
}, [a]), q = Y(
|
|
1127
|
+
(I) => {
|
|
1128
|
+
const x = I.target.value, le = ne(x);
|
|
1129
|
+
le && (r == null || r(x, le));
|
|
1130
|
+
},
|
|
1131
|
+
[r]
|
|
1132
|
+
), j = (I) => {
|
|
1133
|
+
if (o)
|
|
1134
|
+
return `${s ? I.symbol + " " : ""}${I.code}`;
|
|
1135
|
+
const x = [];
|
|
1136
|
+
return s && x.push(I.symbol), d && x.push(I.code), x.push("—", I.name), x.join(" ");
|
|
1137
|
+
}, C = `nice-currency-selector nice-currency-selector--${p} nice-currency-selector--label-${D}` + (o ? " nice-currency-selector--compact" : "") + (g ? " nice-currency-selector--error" : "") + (Q ? " nice-currency-selector--disabled" : "") + (U ? ` ${U}` : ""), L = D === "left" && _ != null ? { width: typeof _ == "number" ? `${_}px` : _, flex: "none" } : void 0, oe = w != null ? {
|
|
1138
|
+
width: typeof w == "number" ? `${w}px` : w,
|
|
1139
|
+
flex: "none"
|
|
1140
|
+
} : void 0;
|
|
1141
|
+
return F ? null : /* @__PURE__ */ b("div", { ref: k, className: C, style: G, title: $, "data-testid": A, children: [
|
|
1142
|
+
u && /* @__PURE__ */ b("label", { htmlFor: te, className: "nice-currency-selector__label", style: L, children: [
|
|
1143
|
+
u,
|
|
1144
|
+
N && /* @__PURE__ */ c("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
|
|
1145
|
+
] }),
|
|
1146
|
+
/* @__PURE__ */ b("div", { className: "nice-currency-selector__inner", style: oe, children: [
|
|
1147
|
+
E && /* @__PURE__ */ c(
|
|
1148
|
+
"input",
|
|
1180
1149
|
{
|
|
1181
|
-
|
|
1182
|
-
|
|
1150
|
+
type: "search",
|
|
1151
|
+
className: "nice-currency-selector__search",
|
|
1152
|
+
placeholder: B("currencySelector.searchCurrency", "Search currency…"),
|
|
1153
|
+
value: J,
|
|
1154
|
+
onChange: (I) => T(I.target.value),
|
|
1155
|
+
disabled: Q || ce,
|
|
1156
|
+
"aria-label": B("currencySelector.searchCurrency2", "Search currency")
|
|
1157
|
+
}
|
|
1158
|
+
),
|
|
1159
|
+
/* @__PURE__ */ b(
|
|
1160
|
+
"select",
|
|
1161
|
+
{
|
|
1162
|
+
id: te,
|
|
1163
|
+
name: S,
|
|
1164
|
+
className: "nice-currency-selector__select",
|
|
1165
|
+
value: e ?? "",
|
|
1166
|
+
onChange: q,
|
|
1167
|
+
disabled: Q || ce,
|
|
1168
|
+
required: N,
|
|
1169
|
+
"aria-invalid": !!g,
|
|
1170
|
+
"aria-label": W ?? (typeof u == "string" ? u : "Currency"),
|
|
1171
|
+
children: [
|
|
1172
|
+
!e && /* @__PURE__ */ c("option", { value: "", children: O ?? "Select currency…" }),
|
|
1173
|
+
h.length > 0 && /* @__PURE__ */ c("optgroup", { label: B("currencySelector.recent", "Recent"), children: h.map((I) => /* @__PURE__ */ c("option", { value: I.code, children: j(I) }, `r-${I.code}`)) }),
|
|
1174
|
+
/* @__PURE__ */ c("optgroup", { label: h.length > 0 ? "All" : "", children: P.map((I) => /* @__PURE__ */ c("option", { value: I.code, children: j(I) }, I.code)) })
|
|
1175
|
+
]
|
|
1183
1176
|
}
|
|
1184
1177
|
)
|
|
1185
|
-
] })
|
|
1186
|
-
|
|
1187
|
-
|
|
1178
|
+
] }),
|
|
1179
|
+
(g || m) && /* @__PURE__ */ c(
|
|
1180
|
+
"span",
|
|
1181
|
+
{
|
|
1182
|
+
className: g ? "nice-currency-selector__error" : "nice-currency-selector__helper",
|
|
1183
|
+
children: g ?? m
|
|
1184
|
+
}
|
|
1185
|
+
)
|
|
1186
|
+
] });
|
|
1187
|
+
}), Ze = /* @__PURE__ */ se(
|
|
1188
1188
|
function({
|
|
1189
1189
|
value: e,
|
|
1190
1190
|
onChange: r,
|
|
1191
|
-
currency:
|
|
1192
|
-
onCurrencyChange:
|
|
1191
|
+
currency: n,
|
|
1192
|
+
onCurrencyChange: a,
|
|
1193
1193
|
currencies: i,
|
|
1194
|
-
hideCurrencySelector:
|
|
1194
|
+
hideCurrencySelector: d,
|
|
1195
1195
|
min: s,
|
|
1196
1196
|
max: o,
|
|
1197
1197
|
step: l,
|
|
1198
|
-
locale:
|
|
1198
|
+
locale: y,
|
|
1199
1199
|
placeholder: v,
|
|
1200
|
-
label:
|
|
1201
|
-
helperText:
|
|
1202
|
-
error:
|
|
1203
|
-
size:
|
|
1204
|
-
disabled:
|
|
1205
|
-
readOnly:
|
|
1206
|
-
required:
|
|
1207
|
-
loading:
|
|
1208
|
-
accessMode:
|
|
1209
|
-
labelPlacement:
|
|
1210
|
-
errorPlacement:
|
|
1211
|
-
labelWidth:
|
|
1212
|
-
controlWidth:
|
|
1213
|
-
submitOnEnter:
|
|
1214
|
-
onSubmit:
|
|
1215
|
-
showFormattedPreview:
|
|
1216
|
-
showSteppers:
|
|
1217
|
-
className:
|
|
1218
|
-
style:
|
|
1219
|
-
id:
|
|
1220
|
-
name:
|
|
1221
|
-
title:
|
|
1222
|
-
"data-testid":
|
|
1223
|
-
onBlur:
|
|
1224
|
-
onFocus:
|
|
1225
|
-
liveGrouping:
|
|
1226
|
-
multiplierShortcuts:
|
|
1227
|
-
onValidationError:
|
|
1228
|
-
},
|
|
1229
|
-
const
|
|
1230
|
-
() => e ? (e.amount / Math.pow(10,
|
|
1231
|
-
), [
|
|
1232
|
-
|
|
1233
|
-
if (
|
|
1200
|
+
label: f,
|
|
1201
|
+
helperText: u,
|
|
1202
|
+
error: m,
|
|
1203
|
+
size: g = "md",
|
|
1204
|
+
disabled: N,
|
|
1205
|
+
readOnly: p,
|
|
1206
|
+
required: D,
|
|
1207
|
+
loading: _,
|
|
1208
|
+
accessMode: w,
|
|
1209
|
+
labelPlacement: U = "top",
|
|
1210
|
+
errorPlacement: G = "bottom",
|
|
1211
|
+
labelWidth: M,
|
|
1212
|
+
controlWidth: S,
|
|
1213
|
+
submitOnEnter: $,
|
|
1214
|
+
onSubmit: A,
|
|
1215
|
+
showFormattedPreview: W = !0,
|
|
1216
|
+
showSteppers: O = !1,
|
|
1217
|
+
className: k,
|
|
1218
|
+
style: B,
|
|
1219
|
+
id: F,
|
|
1220
|
+
name: Q,
|
|
1221
|
+
title: ce,
|
|
1222
|
+
"data-testid": H,
|
|
1223
|
+
onBlur: te,
|
|
1224
|
+
onFocus: J,
|
|
1225
|
+
liveGrouping: T,
|
|
1226
|
+
multiplierShortcuts: E = !0,
|
|
1227
|
+
onValidationError: P
|
|
1228
|
+
}, h) {
|
|
1229
|
+
const { t: q } = pe(), j = N || w === "disabled" || _, C = p || w === "readOnly", L = w === "hidden", oe = _e(), I = F ?? `nice-money-${oe}`, x = ((e == null ? void 0 : e.currency) ?? n ?? "USD").toUpperCase(), le = ne(x), ee = (le == null ? void 0 : le.decimals) ?? 2, xe = l ?? 1 / Math.pow(10, ee), [De, ge] = z(
|
|
1230
|
+
() => e ? (e.amount / Math.pow(10, ee)).toFixed(ee) : ""
|
|
1231
|
+
), [ve, Re] = z(!1);
|
|
1232
|
+
nt.useEffect(() => {
|
|
1233
|
+
if (ve)
|
|
1234
1234
|
return;
|
|
1235
1235
|
if (e == null) {
|
|
1236
|
-
|
|
1236
|
+
ge("");
|
|
1237
1237
|
return;
|
|
1238
1238
|
}
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
}, [e,
|
|
1242
|
-
const
|
|
1243
|
-
(
|
|
1244
|
-
let
|
|
1245
|
-
if (
|
|
1246
|
-
const
|
|
1247
|
-
if (
|
|
1248
|
-
const
|
|
1249
|
-
if (!Number.isFinite(
|
|
1250
|
-
|
|
1239
|
+
const R = ne(e.currency), X = (R == null ? void 0 : R.decimals) ?? 2;
|
|
1240
|
+
ge((e.amount / Math.pow(10, X)).toFixed(X));
|
|
1241
|
+
}, [e, ve]);
|
|
1242
|
+
const Ue = Y(
|
|
1243
|
+
(R) => {
|
|
1244
|
+
let X = R;
|
|
1245
|
+
if (E) {
|
|
1246
|
+
const ue = R.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);
|
|
1247
|
+
if (ue) {
|
|
1248
|
+
const me = ue[2].toLowerCase() === "k" ? 1e3 : ue[2].toLowerCase() === "m" ? 1e6 : 1e9, Fe = Number(ue[1].replace(",", ".")) * me;
|
|
1249
|
+
if (!Number.isFinite(Fe)) {
|
|
1250
|
+
P == null || P(new Error("overflow"));
|
|
1251
1251
|
return;
|
|
1252
1252
|
}
|
|
1253
|
-
|
|
1253
|
+
X = String(Fe);
|
|
1254
1254
|
}
|
|
1255
1255
|
}
|
|
1256
|
-
const
|
|
1257
|
-
if (!
|
|
1256
|
+
const re = ut(X, x);
|
|
1257
|
+
if (!re) {
|
|
1258
1258
|
r == null || r(null);
|
|
1259
1259
|
return;
|
|
1260
1260
|
}
|
|
1261
|
-
if (!Number.isSafeInteger(
|
|
1262
|
-
|
|
1261
|
+
if (!Number.isSafeInteger(re.amount)) {
|
|
1262
|
+
P == null || P(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));
|
|
1263
1263
|
return;
|
|
1264
1264
|
}
|
|
1265
|
-
const
|
|
1266
|
-
if (s != null &&
|
|
1267
|
-
|
|
1265
|
+
const de = re.amount / Math.pow(10, ee);
|
|
1266
|
+
if (s != null && de < s) {
|
|
1267
|
+
P == null || P(new Error(`min: ${s}`)), r == null || r(ae(s, x));
|
|
1268
1268
|
return;
|
|
1269
1269
|
}
|
|
1270
|
-
if (o != null &&
|
|
1271
|
-
|
|
1270
|
+
if (o != null && de > o) {
|
|
1271
|
+
P == null || P(new Error(`max: ${o}`)), r == null || r(ae(o, x));
|
|
1272
1272
|
return;
|
|
1273
1273
|
}
|
|
1274
|
-
r == null || r(
|
|
1274
|
+
r == null || r(re);
|
|
1275
1275
|
},
|
|
1276
|
-
[
|
|
1277
|
-
),
|
|
1278
|
-
(
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1276
|
+
[x, ee, s, o, r, E, P]
|
|
1277
|
+
), Je = Y(
|
|
1278
|
+
(R) => {
|
|
1279
|
+
const X = R.target.value;
|
|
1280
|
+
ge(X), Ue(X);
|
|
1281
1281
|
},
|
|
1282
|
-
[
|
|
1283
|
-
),
|
|
1284
|
-
(
|
|
1285
|
-
const
|
|
1286
|
-
r == null || r(
|
|
1282
|
+
[Ue]
|
|
1283
|
+
), Ae = Y(
|
|
1284
|
+
(R) => {
|
|
1285
|
+
const re = (e ? e.amount / Math.pow(10, ee) : 0) + R, de = Math.min(o ?? 1 / 0, Math.max(s ?? -1 / 0, re));
|
|
1286
|
+
r == null || r(ae(de, x));
|
|
1287
1287
|
},
|
|
1288
|
-
[e,
|
|
1289
|
-
),
|
|
1290
|
-
var
|
|
1288
|
+
[e, ee, s, o, x, r]
|
|
1289
|
+
), Ne = K(() => {
|
|
1290
|
+
var R, X;
|
|
1291
1291
|
try {
|
|
1292
|
-
const
|
|
1293
|
-
return { group:
|
|
1292
|
+
const re = new Intl.NumberFormat(y).formatToParts(12345.6), de = ((R = re.find((me) => me.type === "group")) == null ? void 0 : R.value) ?? ",", ue = ((X = re.find((me) => me.type === "decimal")) == null ? void 0 : X.value) ?? ".";
|
|
1293
|
+
return { group: de, decimal: ue };
|
|
1294
1294
|
} catch {
|
|
1295
1295
|
return { group: ",", decimal: "." };
|
|
1296
1296
|
}
|
|
1297
|
-
}, [
|
|
1298
|
-
if (!
|
|
1299
|
-
return
|
|
1300
|
-
const
|
|
1301
|
-
new RegExp(`[${
|
|
1297
|
+
}, [y]), Ee = T ?? !!Ne.group, Xe = K(() => {
|
|
1298
|
+
if (!Ee || ve === !1)
|
|
1299
|
+
return De;
|
|
1300
|
+
const R = Ne.decimal, X = Ne.group, re = De.replace(
|
|
1301
|
+
new RegExp(`[${X.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`, "g"),
|
|
1302
1302
|
""
|
|
1303
|
-
), [
|
|
1304
|
-
if (!
|
|
1305
|
-
return
|
|
1306
|
-
const
|
|
1307
|
-
return
|
|
1308
|
-
}, [
|
|
1309
|
-
|
|
1310
|
-
},
|
|
1311
|
-
width: typeof
|
|
1303
|
+
), [de, ue] = re.split(R);
|
|
1304
|
+
if (!de)
|
|
1305
|
+
return re;
|
|
1306
|
+
const me = de.replace(/\B(?=(\d{3})+(?!\d))/g, X);
|
|
1307
|
+
return ue != null ? `${me}${R}${ue}` : me;
|
|
1308
|
+
}, [De, ve, Ee, Ne]), Te = K(() => e ? ie(e, { locale: y }) : "", [e, y]), he = typeof m == "string" ? m : void 0, Qe = `nice-money-input nice-money-input--${g} nice-money-input--label-${U} nice-money-input--error-${G}` + (he ? " nice-money-input--error" : "") + (j ? " nice-money-input--disabled" : "") + (_ ? " nice-money-input--loading" : "") + (k ? ` ${k}` : ""), Ve = (R) => {
|
|
1309
|
+
$ && R.key === "Enter" && A && (R.preventDefault(), A());
|
|
1310
|
+
}, We = U === "left" && M != null ? { width: typeof M == "number" ? `${M}px` : M, flex: "none" } : void 0, et = S != null ? {
|
|
1311
|
+
width: typeof S == "number" ? `${S}px` : S,
|
|
1312
1312
|
flex: "none"
|
|
1313
1313
|
} : void 0;
|
|
1314
|
-
return
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1314
|
+
return L ? null : /* @__PURE__ */ b("div", { ref: h, className: Qe, style: B, title: ce, "data-testid": H, children: [
|
|
1315
|
+
f && /* @__PURE__ */ b("label", { htmlFor: I, className: "nice-money-input__label", style: We, children: [
|
|
1316
|
+
f,
|
|
1317
|
+
D && /* @__PURE__ */ c("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
|
|
1318
1318
|
] }),
|
|
1319
|
-
/* @__PURE__ */
|
|
1320
|
-
!
|
|
1321
|
-
|
|
1319
|
+
/* @__PURE__ */ b("div", { className: "nice-money-input__row", style: et, children: [
|
|
1320
|
+
!d && /* @__PURE__ */ c(
|
|
1321
|
+
Ge,
|
|
1322
1322
|
{
|
|
1323
|
-
value:
|
|
1323
|
+
value: x,
|
|
1324
1324
|
compact: !0,
|
|
1325
|
-
options: i ? i.map(
|
|
1326
|
-
onChange: (
|
|
1327
|
-
disabled:
|
|
1325
|
+
options: i ? i.map(ne).filter((R) => !!R) : void 0,
|
|
1326
|
+
onChange: (R) => a == null ? void 0 : a(R),
|
|
1327
|
+
disabled: j || C,
|
|
1328
1328
|
className: "nice-money-input__currency",
|
|
1329
|
-
"aria-label": "Currency"
|
|
1329
|
+
"aria-label": q("moneyInput.currency", "Currency")
|
|
1330
1330
|
}
|
|
1331
1331
|
),
|
|
1332
|
-
|
|
1333
|
-
|
|
1332
|
+
d && /* @__PURE__ */ c("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (le == null ? void 0 : le.symbol) ?? x }),
|
|
1333
|
+
O && /* @__PURE__ */ c(
|
|
1334
1334
|
"button",
|
|
1335
1335
|
{
|
|
1336
1336
|
type: "button",
|
|
1337
1337
|
className: "nice-money-input__step nice-money-input__step--down",
|
|
1338
|
-
onClick: () =>
|
|
1339
|
-
disabled:
|
|
1340
|
-
"aria-label": "Decrease amount",
|
|
1338
|
+
onClick: () => Ae(-xe),
|
|
1339
|
+
disabled: j || C || s != null && e != null && e.amount / Math.pow(10, ee) <= s,
|
|
1340
|
+
"aria-label": q("moneyInput.decreaseAmount", "Decrease amount"),
|
|
1341
1341
|
tabIndex: -1,
|
|
1342
1342
|
children: "−"
|
|
1343
1343
|
}
|
|
@@ -1345,244 +1345,242 @@ const qe = ie(function({
|
|
|
1345
1345
|
/* @__PURE__ */ c(
|
|
1346
1346
|
"input",
|
|
1347
1347
|
{
|
|
1348
|
-
id:
|
|
1349
|
-
name:
|
|
1348
|
+
id: I,
|
|
1349
|
+
name: Q,
|
|
1350
1350
|
type: "text",
|
|
1351
1351
|
inputMode: "decimal",
|
|
1352
1352
|
autoComplete: "transaction-amount",
|
|
1353
1353
|
className: "nice-money-input__amount",
|
|
1354
|
-
value:
|
|
1355
|
-
onChange:
|
|
1356
|
-
onKeyDown:
|
|
1357
|
-
onFocus: (
|
|
1358
|
-
|
|
1354
|
+
value: Xe,
|
|
1355
|
+
onChange: Je,
|
|
1356
|
+
onKeyDown: Ve,
|
|
1357
|
+
onFocus: (R) => {
|
|
1358
|
+
Re(!0), J == null || J(R);
|
|
1359
1359
|
},
|
|
1360
|
-
onBlur: (
|
|
1361
|
-
|
|
1360
|
+
onBlur: (R) => {
|
|
1361
|
+
Re(!1), e && ge((e.amount / Math.pow(10, ee)).toFixed(ee)), te == null || te(R);
|
|
1362
1362
|
},
|
|
1363
|
-
placeholder: v ?? `0${
|
|
1364
|
-
disabled:
|
|
1363
|
+
placeholder: v ?? `0${ee > 0 ? "." + "0".repeat(ee) : ""}`,
|
|
1364
|
+
disabled: j,
|
|
1365
1365
|
readOnly: C,
|
|
1366
|
-
required:
|
|
1367
|
-
"aria-invalid": !!
|
|
1368
|
-
"aria-describedby":
|
|
1366
|
+
required: D,
|
|
1367
|
+
"aria-invalid": !!he,
|
|
1368
|
+
"aria-describedby": he || u ? `${I}-help` : void 0
|
|
1369
1369
|
}
|
|
1370
1370
|
),
|
|
1371
|
-
|
|
1371
|
+
O && /* @__PURE__ */ c(
|
|
1372
1372
|
"button",
|
|
1373
1373
|
{
|
|
1374
1374
|
type: "button",
|
|
1375
1375
|
className: "nice-money-input__step nice-money-input__step--up",
|
|
1376
|
-
onClick: () =>
|
|
1377
|
-
disabled:
|
|
1378
|
-
"aria-label": "Increase amount",
|
|
1376
|
+
onClick: () => Ae(xe),
|
|
1377
|
+
disabled: j || C || o != null && e != null && e.amount / Math.pow(10, ee) >= o,
|
|
1378
|
+
"aria-label": q("moneyInput.increaseAmount", "Increase amount"),
|
|
1379
1379
|
tabIndex: -1,
|
|
1380
1380
|
children: "+"
|
|
1381
1381
|
}
|
|
1382
1382
|
),
|
|
1383
|
-
|
|
1383
|
+
_ && /* @__PURE__ */ c("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: /* @__PURE__ */ c(Me, { name: "refresh", size: 14 }) })
|
|
1384
1384
|
] }),
|
|
1385
|
-
|
|
1386
|
-
(
|
|
1385
|
+
W && Te && /* @__PURE__ */ c("span", { className: "nice-money-input__preview", "aria-live": "polite", children: Te }),
|
|
1386
|
+
(he || u) && /* @__PURE__ */ c(
|
|
1387
1387
|
"span",
|
|
1388
1388
|
{
|
|
1389
|
-
id: `${
|
|
1390
|
-
className:
|
|
1391
|
-
children:
|
|
1389
|
+
id: `${I}-help`,
|
|
1390
|
+
className: he ? "nice-money-input__error" : "nice-money-input__helper",
|
|
1391
|
+
children: he ?? u
|
|
1392
1392
|
}
|
|
1393
1393
|
)
|
|
1394
1394
|
] });
|
|
1395
1395
|
}
|
|
1396
|
-
),
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
}, A) {
|
|
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
|
-
] })
|
|
1396
|
+
), Bt = { number: "", expiry: "", cvc: "" }, Lt = /* @__PURE__ */ se(function({
|
|
1397
|
+
value: e = Bt,
|
|
1398
|
+
onChange: r,
|
|
1399
|
+
showHolderName: n = !0,
|
|
1400
|
+
requireHolderName: a,
|
|
1401
|
+
showPostalCode: i = !1,
|
|
1402
|
+
acceptedBrands: d,
|
|
1403
|
+
showBrandIcon: s = !0,
|
|
1404
|
+
size: o = "md",
|
|
1405
|
+
disabled: l,
|
|
1406
|
+
readOnly: y,
|
|
1407
|
+
loading: v,
|
|
1408
|
+
accessMode: f,
|
|
1409
|
+
label: u,
|
|
1410
|
+
helperText: m,
|
|
1411
|
+
error: g,
|
|
1412
|
+
required: N,
|
|
1413
|
+
className: p,
|
|
1414
|
+
style: D,
|
|
1415
|
+
id: _,
|
|
1416
|
+
title: w,
|
|
1417
|
+
"data-testid": U
|
|
1418
|
+
}, G) {
|
|
1419
|
+
const { t: M } = pe(), S = f === "hidden", $ = l || f === "disabled" || v, A = y || f === "readOnly", W = _e(), O = _ ?? `nice-cc-${W}`, [k, B] = z({
|
|
1420
|
+
number: !1,
|
|
1421
|
+
expiry: !1,
|
|
1422
|
+
cvc: !1,
|
|
1423
|
+
holder: !1,
|
|
1424
|
+
postal: !1
|
|
1425
|
+
}), F = K(() => ke(e.number), [e.number]), Q = K(
|
|
1426
|
+
() => qe(e, { requireHolder: a ?? n }),
|
|
1427
|
+
[e, a, n]
|
|
1428
|
+
), ce = !d || d.includes(F) || F === "unknown", H = Y(
|
|
1429
|
+
(C) => {
|
|
1430
|
+
const L = { ...e, ...C }, oe = qe(L, { requireHolder: a ?? n });
|
|
1431
|
+
r == null || r(L, oe);
|
|
1432
|
+
},
|
|
1433
|
+
[e, a, n, r]
|
|
1434
|
+
), te = Y(
|
|
1435
|
+
(C) => {
|
|
1436
|
+
const L = C.target.value.replace(/\D/g, "").slice(0, 19);
|
|
1437
|
+
H({ number: L });
|
|
1438
|
+
},
|
|
1439
|
+
[H]
|
|
1440
|
+
), J = Y(
|
|
1441
|
+
(C) => {
|
|
1442
|
+
const L = C.target.value.replace(/\D/g, "").slice(0, 4);
|
|
1443
|
+
let oe = L;
|
|
1444
|
+
L.length >= 3 ? oe = `${L.slice(0, 2)}/${L.slice(2)}` : L.length === 2 && (oe = `${L}/`), H({ expiry: oe });
|
|
1445
|
+
},
|
|
1446
|
+
[H]
|
|
1447
|
+
), T = Y(
|
|
1448
|
+
(C) => {
|
|
1449
|
+
const L = C.target.value.replace(/\D/g, "").slice(0, be(F));
|
|
1450
|
+
H({ cvc: L });
|
|
1451
|
+
},
|
|
1452
|
+
[F, H]
|
|
1453
|
+
), E = K(() => mt(e.number, F), [e.number, F]), P = k.number && e.number.length > 0 && (ze(e.number) ? ce ? void 0 : "Card brand not accepted" : Q.errors.number), h = k.expiry && e.expiry.length > 0 && !Ye(e.expiry) ? Q.errors.expiry : void 0, q = k.cvc && e.cvc.length > 0 && e.cvc.length !== be(F) ? Q.errors.cvc : void 0, j = `nice-credit-card nice-credit-card--${o}` + ($ ? " nice-credit-card--disabled" : "") + (v ? " nice-credit-card--loading" : "") + (g ? " nice-credit-card--error" : "") + (p ? ` ${p}` : "");
|
|
1454
|
+
return S ? null : /* @__PURE__ */ b("div", { ref: G, className: j, style: D, title: w, "data-testid": U, children: [
|
|
1455
|
+
u && /* @__PURE__ */ b("div", { className: "nice-credit-card__title", children: [
|
|
1456
|
+
u,
|
|
1457
|
+
N && /* @__PURE__ */ c("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
|
|
1458
|
+
] }),
|
|
1459
|
+
/* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ b("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
|
|
1460
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: M("creditCardInput.cardNumber", "Card number") }),
|
|
1461
|
+
/* @__PURE__ */ b("span", { className: "nice-credit-card__input-wrapper", children: [
|
|
1462
|
+
/* @__PURE__ */ c(
|
|
1463
|
+
"input",
|
|
1464
|
+
{
|
|
1465
|
+
id: `${O}-number`,
|
|
1466
|
+
type: "text",
|
|
1467
|
+
inputMode: "numeric",
|
|
1468
|
+
autoComplete: "cc-number",
|
|
1469
|
+
placeholder: F === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
|
|
1470
|
+
value: E,
|
|
1471
|
+
onChange: te,
|
|
1472
|
+
onBlur: () => B((C) => ({ ...C, number: !0 })),
|
|
1473
|
+
disabled: $,
|
|
1474
|
+
readOnly: A,
|
|
1475
|
+
"aria-invalid": !!P,
|
|
1476
|
+
"aria-describedby": P ? `${O}-number-err` : void 0,
|
|
1477
|
+
className: "nice-credit-card__input",
|
|
1478
|
+
maxLength: F === "amex" ? 17 : 23
|
|
1479
|
+
}
|
|
1480
|
+
),
|
|
1481
|
+
s && /* @__PURE__ */ c(Ht, { brand: F })
|
|
1537
1482
|
] }),
|
|
1538
|
-
|
|
1539
|
-
|
|
1483
|
+
P && /* @__PURE__ */ c("span", { id: `${O}-number-err`, className: "nice-credit-card__error", children: P })
|
|
1484
|
+
] }) }),
|
|
1485
|
+
/* @__PURE__ */ b("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
|
|
1486
|
+
/* @__PURE__ */ b("label", { className: "nice-credit-card__field", children: [
|
|
1487
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: M("creditCardInput.expiry", "Expiry") }),
|
|
1540
1488
|
/* @__PURE__ */ c(
|
|
1541
1489
|
"input",
|
|
1542
1490
|
{
|
|
1543
|
-
id: `${O}-
|
|
1491
|
+
id: `${O}-expiry`,
|
|
1544
1492
|
type: "text",
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1493
|
+
inputMode: "numeric",
|
|
1494
|
+
autoComplete: "cc-exp",
|
|
1495
|
+
placeholder: M("creditCardInput.mmYy", "MM/YY"),
|
|
1496
|
+
value: e.expiry,
|
|
1497
|
+
onChange: J,
|
|
1498
|
+
onBlur: () => {
|
|
1499
|
+
B((L) => ({ ...L, expiry: !0 }));
|
|
1500
|
+
const C = je(e.expiry);
|
|
1501
|
+
C && C !== e.expiry && H({ expiry: C });
|
|
1502
|
+
},
|
|
1503
|
+
disabled: $,
|
|
1504
|
+
readOnly: A,
|
|
1505
|
+
"aria-invalid": !!h,
|
|
1506
|
+
"aria-describedby": h ? `${O}-expiry-err` : void 0,
|
|
1552
1507
|
className: "nice-credit-card__input",
|
|
1553
|
-
maxLength:
|
|
1508
|
+
maxLength: 5
|
|
1554
1509
|
}
|
|
1555
|
-
)
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1510
|
+
),
|
|
1511
|
+
h && /* @__PURE__ */ c("span", { id: `${O}-expiry-err`, className: "nice-credit-card__error", children: h })
|
|
1512
|
+
] }),
|
|
1513
|
+
/* @__PURE__ */ b("label", { className: "nice-credit-card__field", children: [
|
|
1514
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: F === "amex" ? "CID" : "CVC" }),
|
|
1559
1515
|
/* @__PURE__ */ c(
|
|
1560
1516
|
"input",
|
|
1561
1517
|
{
|
|
1562
|
-
id: `${O}-
|
|
1518
|
+
id: `${O}-cvc`,
|
|
1563
1519
|
type: "text",
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1520
|
+
inputMode: "numeric",
|
|
1521
|
+
autoComplete: "cc-csc",
|
|
1522
|
+
placeholder: "•".repeat(be(F)),
|
|
1523
|
+
value: e.cvc,
|
|
1524
|
+
onChange: T,
|
|
1525
|
+
onBlur: () => B((C) => ({ ...C, cvc: !0 })),
|
|
1526
|
+
disabled: $,
|
|
1527
|
+
readOnly: A,
|
|
1528
|
+
"aria-invalid": !!q,
|
|
1529
|
+
"aria-describedby": q ? `${O}-cvc-err` : void 0,
|
|
1570
1530
|
className: "nice-credit-card__input",
|
|
1571
|
-
maxLength:
|
|
1531
|
+
maxLength: be(F)
|
|
1572
1532
|
}
|
|
1573
|
-
)
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1533
|
+
),
|
|
1534
|
+
q && /* @__PURE__ */ c("span", { id: `${O}-cvc-err`, className: "nice-credit-card__error", children: q })
|
|
1535
|
+
] })
|
|
1536
|
+
] }),
|
|
1537
|
+
n && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ b("label", { className: "nice-credit-card__field", children: [
|
|
1538
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: M("creditCardInput.cardholderName", "Cardholder name") }),
|
|
1539
|
+
/* @__PURE__ */ c(
|
|
1540
|
+
"input",
|
|
1577
1541
|
{
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1542
|
+
id: `${O}-holder`,
|
|
1543
|
+
type: "text",
|
|
1544
|
+
autoComplete: "cc-name",
|
|
1545
|
+
placeholder: M("creditCardInput.janeDoe", "Jane Doe"),
|
|
1546
|
+
value: e.holderName ?? "",
|
|
1547
|
+
onChange: (C) => H({ holderName: C.target.value }),
|
|
1548
|
+
onBlur: () => B((C) => ({ ...C, holder: !0 })),
|
|
1549
|
+
disabled: $,
|
|
1550
|
+
readOnly: A,
|
|
1551
|
+
className: "nice-credit-card__input",
|
|
1552
|
+
maxLength: 120
|
|
1581
1553
|
}
|
|
1582
1554
|
)
|
|
1583
|
-
] })
|
|
1584
|
-
|
|
1585
|
-
|
|
1555
|
+
] }) }),
|
|
1556
|
+
i && /* @__PURE__ */ c("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ b("label", { className: "nice-credit-card__field", children: [
|
|
1557
|
+
/* @__PURE__ */ c("span", { className: "nice-credit-card__label", children: M("creditCardInput.postalCode", "Postal code") }),
|
|
1558
|
+
/* @__PURE__ */ c(
|
|
1559
|
+
"input",
|
|
1560
|
+
{
|
|
1561
|
+
id: `${O}-postal`,
|
|
1562
|
+
type: "text",
|
|
1563
|
+
autoComplete: "postal-code",
|
|
1564
|
+
value: e.postalCode ?? "",
|
|
1565
|
+
onChange: (C) => H({ postalCode: C.target.value }),
|
|
1566
|
+
onBlur: () => B((C) => ({ ...C, postal: !0 })),
|
|
1567
|
+
disabled: $,
|
|
1568
|
+
readOnly: A,
|
|
1569
|
+
className: "nice-credit-card__input",
|
|
1570
|
+
maxLength: 16
|
|
1571
|
+
}
|
|
1572
|
+
)
|
|
1573
|
+
] }) }),
|
|
1574
|
+
(g || m) && /* @__PURE__ */ c(
|
|
1575
|
+
"div",
|
|
1576
|
+
{
|
|
1577
|
+
className: g ? "nice-credit-card__form-error" : "nice-credit-card__helper",
|
|
1578
|
+
role: g ? "alert" : void 0,
|
|
1579
|
+
children: g ?? m
|
|
1580
|
+
}
|
|
1581
|
+
)
|
|
1582
|
+
] });
|
|
1583
|
+
}), Oe = {
|
|
1586
1584
|
visa: "VISA",
|
|
1587
1585
|
mastercard: "MasterCard",
|
|
1588
1586
|
amex: "AMEX",
|
|
@@ -1596,146 +1594,149 @@ const qe = ie(function({
|
|
|
1596
1594
|
hipercard: "Hipercard",
|
|
1597
1595
|
unknown: ""
|
|
1598
1596
|
};
|
|
1599
|
-
function
|
|
1597
|
+
function Ht({ brand: t }) {
|
|
1600
1598
|
return t === "unknown" ? null : /* @__PURE__ */ c(
|
|
1601
1599
|
"span",
|
|
1602
1600
|
{
|
|
1603
1601
|
className: `nice-credit-card__brand nice-credit-card__brand--${t}`,
|
|
1604
|
-
"aria-label":
|
|
1605
|
-
children:
|
|
1602
|
+
"aria-label": Oe[t],
|
|
1603
|
+
children: Oe[t]
|
|
1606
1604
|
}
|
|
1607
1605
|
);
|
|
1608
1606
|
}
|
|
1609
|
-
const
|
|
1607
|
+
const yr = /* @__PURE__ */ se(
|
|
1610
1608
|
function({
|
|
1611
1609
|
processor: e,
|
|
1612
1610
|
amount: r,
|
|
1613
|
-
editableAmount:
|
|
1614
|
-
customer:
|
|
1611
|
+
editableAmount: n,
|
|
1612
|
+
customer: a,
|
|
1615
1613
|
currencies: i,
|
|
1616
|
-
description:
|
|
1614
|
+
description: d,
|
|
1617
1615
|
metadata: s,
|
|
1618
1616
|
autoCapture: o = !0,
|
|
1619
1617
|
submitLabel: l = "Pay",
|
|
1620
|
-
onSuccess:
|
|
1618
|
+
onSuccess: y,
|
|
1621
1619
|
onError: v,
|
|
1622
|
-
consents:
|
|
1623
|
-
className:
|
|
1624
|
-
style:
|
|
1625
|
-
},
|
|
1626
|
-
const [
|
|
1620
|
+
consents: f,
|
|
1621
|
+
className: u,
|
|
1622
|
+
style: m
|
|
1623
|
+
}, g) {
|
|
1624
|
+
const { t: N } = pe(), [p, D] = z(r), [_, w] = z(r.currency), [U, G] = z({ number: "", expiry: "", cvc: "" }), [M, S] = z(null), [$, A] = z(!1), [W, O] = z(null), k = Ot(e), B = K(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(p.currency.toUpperCase()), [e, p.currency]), F = K(() => {
|
|
1627
1625
|
var E;
|
|
1628
|
-
const
|
|
1629
|
-
return
|
|
1630
|
-
}, [e,
|
|
1626
|
+
const T = (E = e.minimums) == null ? void 0 : E[p.currency.toUpperCase()];
|
|
1627
|
+
return T == null || p.amount >= T;
|
|
1628
|
+
}, [e, p]), Q = K(() => {
|
|
1631
1629
|
var E;
|
|
1632
|
-
const
|
|
1633
|
-
return
|
|
1634
|
-
}, [e,
|
|
1635
|
-
async (
|
|
1636
|
-
if (
|
|
1637
|
-
O(null),
|
|
1630
|
+
const T = (E = e.minimums) == null ? void 0 : E[p.currency.toUpperCase()];
|
|
1631
|
+
return T == null ? null : { amount: T, currency: p.currency };
|
|
1632
|
+
}, [e, p.currency]), ce = !!(M != null && M.isValid), H = !$ && B && F && ce, te = Y(
|
|
1633
|
+
async (T) => {
|
|
1634
|
+
if (T.preventDefault(), !!H) {
|
|
1635
|
+
O(null), A(!0);
|
|
1638
1636
|
try {
|
|
1639
1637
|
const E = {
|
|
1640
|
-
amount:
|
|
1641
|
-
card:
|
|
1642
|
-
customer:
|
|
1643
|
-
description:
|
|
1638
|
+
amount: p,
|
|
1639
|
+
card: U,
|
|
1640
|
+
customer: a,
|
|
1641
|
+
description: d,
|
|
1644
1642
|
metadata: s,
|
|
1645
|
-
idempotencyKey:
|
|
1646
|
-
},
|
|
1647
|
-
if (o &&
|
|
1648
|
-
const
|
|
1649
|
-
|
|
1643
|
+
idempotencyKey: zt()
|
|
1644
|
+
}, P = await k.authorize(E);
|
|
1645
|
+
if (o && P.status === "authorized") {
|
|
1646
|
+
const h = await k.capture(P.id, p);
|
|
1647
|
+
y == null || y(h);
|
|
1650
1648
|
} else
|
|
1651
|
-
|
|
1649
|
+
y == null || y(P);
|
|
1652
1650
|
} catch (E) {
|
|
1653
|
-
const
|
|
1654
|
-
O(
|
|
1651
|
+
const P = E instanceof Error ? E : new Error(String(E));
|
|
1652
|
+
O(P.message), v == null || v(P);
|
|
1655
1653
|
} finally {
|
|
1656
|
-
|
|
1654
|
+
A(!1);
|
|
1657
1655
|
}
|
|
1658
1656
|
}
|
|
1659
1657
|
},
|
|
1660
1658
|
[
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1659
|
+
H,
|
|
1660
|
+
p,
|
|
1661
|
+
U,
|
|
1662
|
+
a,
|
|
1663
|
+
d,
|
|
1666
1664
|
s,
|
|
1667
1665
|
o,
|
|
1668
1666
|
k,
|
|
1669
|
-
|
|
1667
|
+
y,
|
|
1670
1668
|
v
|
|
1671
1669
|
]
|
|
1672
|
-
),
|
|
1673
|
-
return /* @__PURE__ */
|
|
1670
|
+
), J = ne(p.currency);
|
|
1671
|
+
return /* @__PURE__ */ b(
|
|
1674
1672
|
"form",
|
|
1675
1673
|
{
|
|
1676
|
-
ref:
|
|
1677
|
-
className: "nice-payment-form" + (
|
|
1678
|
-
style:
|
|
1679
|
-
onSubmit:
|
|
1680
|
-
"aria-busy":
|
|
1674
|
+
ref: g,
|
|
1675
|
+
className: "nice-payment-form" + (u ? ` ${u}` : ""),
|
|
1676
|
+
style: m,
|
|
1677
|
+
onSubmit: te,
|
|
1678
|
+
"aria-busy": $,
|
|
1681
1679
|
children: [
|
|
1682
|
-
/* @__PURE__ */ c("div", { className: "nice-payment-form__amount", children:
|
|
1683
|
-
|
|
1680
|
+
/* @__PURE__ */ c("div", { className: "nice-payment-form__amount", children: n ? /* @__PURE__ */ c(
|
|
1681
|
+
Ze,
|
|
1684
1682
|
{
|
|
1685
|
-
label: "Amount",
|
|
1686
|
-
value:
|
|
1687
|
-
currency:
|
|
1683
|
+
label: N("paymentForm.amount", "Amount"),
|
|
1684
|
+
value: p,
|
|
1685
|
+
currency: _,
|
|
1688
1686
|
currencies: i,
|
|
1689
|
-
onChange: (
|
|
1690
|
-
onCurrencyChange: (
|
|
1691
|
-
|
|
1687
|
+
onChange: (T) => T && D(T),
|
|
1688
|
+
onCurrencyChange: (T) => {
|
|
1689
|
+
w(T), D((E) => ({ ...E, currency: T }));
|
|
1692
1690
|
},
|
|
1693
|
-
disabled:
|
|
1691
|
+
disabled: $,
|
|
1694
1692
|
required: !0,
|
|
1695
1693
|
showFormattedPreview: !0
|
|
1696
1694
|
}
|
|
1697
|
-
) : /* @__PURE__ */
|
|
1698
|
-
/* @__PURE__ */ c("span", { className: "nice-payment-form__total-label", children: "Total" }),
|
|
1699
|
-
/* @__PURE__ */ c(
|
|
1695
|
+
) : /* @__PURE__ */ b("div", { className: "nice-payment-form__total", children: [
|
|
1696
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-form__total-label", children: N("paymentForm.total", "Total") }),
|
|
1697
|
+
/* @__PURE__ */ c(Ke, { value: p })
|
|
1700
1698
|
] }) }),
|
|
1701
|
-
|
|
1699
|
+
d && /* @__PURE__ */ c("p", { className: "nice-payment-form__description", children: d }),
|
|
1702
1700
|
/* @__PURE__ */ c("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ c(
|
|
1703
|
-
|
|
1701
|
+
Lt,
|
|
1704
1702
|
{
|
|
1705
|
-
value:
|
|
1706
|
-
onChange: (
|
|
1707
|
-
|
|
1703
|
+
value: U,
|
|
1704
|
+
onChange: (T, E) => {
|
|
1705
|
+
G(T), S(E);
|
|
1708
1706
|
},
|
|
1709
|
-
disabled:
|
|
1707
|
+
disabled: $
|
|
1710
1708
|
}
|
|
1711
1709
|
) }),
|
|
1712
|
-
!
|
|
1710
|
+
!B && /* @__PURE__ */ b("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1713
1711
|
e.name,
|
|
1714
1712
|
" does not accept ",
|
|
1715
|
-
(
|
|
1713
|
+
(J == null ? void 0 : J.name) ?? p.currency,
|
|
1716
1714
|
"."
|
|
1717
1715
|
] }),
|
|
1718
|
-
!
|
|
1719
|
-
"Minimum charge for "
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1716
|
+
!F && Q && /* @__PURE__ */ b("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1717
|
+
N("paymentForm.minimumChargeForIs", "Minimum charge for {name} is").replace(
|
|
1718
|
+
"{name}",
|
|
1719
|
+
String(e.name)
|
|
1720
|
+
),
|
|
1721
|
+
" ",
|
|
1722
|
+
/* @__PURE__ */ c(Ke, { value: Q }),
|
|
1723
1723
|
"."
|
|
1724
1724
|
] }),
|
|
1725
|
-
|
|
1726
|
-
|
|
1725
|
+
f && /* @__PURE__ */ c("div", { className: "nice-payment-form__consents", children: f }),
|
|
1726
|
+
W && /* @__PURE__ */ c("div", { className: "nice-payment-form__error", role: "alert", children: W }),
|
|
1727
1727
|
/* @__PURE__ */ c(
|
|
1728
1728
|
"button",
|
|
1729
1729
|
{
|
|
1730
1730
|
type: "submit",
|
|
1731
1731
|
className: "nice-payment-form__submit",
|
|
1732
|
-
disabled: !
|
|
1733
|
-
"aria-disabled": !
|
|
1734
|
-
children:
|
|
1732
|
+
disabled: !H,
|
|
1733
|
+
"aria-disabled": !H,
|
|
1734
|
+
children: $ ? "Processing…" : l
|
|
1735
1735
|
}
|
|
1736
1736
|
),
|
|
1737
|
-
/* @__PURE__ */
|
|
1738
|
-
"Secured by
|
|
1737
|
+
/* @__PURE__ */ b("p", { className: "nice-payment-form__processor", children: [
|
|
1738
|
+
N("paymentForm.securedBy", "Secured by"),
|
|
1739
|
+
" ",
|
|
1739
1740
|
/* @__PURE__ */ c("strong", { children: e.name })
|
|
1740
1741
|
] })
|
|
1741
1742
|
]
|
|
@@ -1743,285 +1744,290 @@ const dr = ie(
|
|
|
1743
1744
|
);
|
|
1744
1745
|
}
|
|
1745
1746
|
);
|
|
1746
|
-
function
|
|
1747
|
+
function zt() {
|
|
1747
1748
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
1748
1749
|
}
|
|
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(
|
|
1750
|
+
const hr = /* @__PURE__ */ se(
|
|
1777
1751
|
function({
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1752
|
+
price: e,
|
|
1753
|
+
originalPrice: r,
|
|
1754
|
+
period: n,
|
|
1755
|
+
prefix: a,
|
|
1756
|
+
suffix: i,
|
|
1757
|
+
showDiscountBadge: d = !0,
|
|
1758
|
+
size: s = "md",
|
|
1785
1759
|
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
|
-
"div",
|
|
1812
|
-
{
|
|
1813
|
-
ref: y,
|
|
1814
|
-
className: "nice-currency-converter" + (p ? ` ${p}` : ""),
|
|
1815
|
-
style: v,
|
|
1816
|
-
children: [
|
|
1817
|
-
/* @__PURE__ */ c("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ c(
|
|
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
|
-
);
|
|
1760
|
+
className: l,
|
|
1761
|
+
style: y
|
|
1762
|
+
}, v) {
|
|
1763
|
+
const { t: f } = pe(), u = r && r.currency === e.currency && r.amount > e.amount, m = K(() => !u || !r ? null : Math.round((r.amount - e.amount) / r.amount * 100), [u, r, e.amount]), g = `nice-price-tag nice-price-tag--${s}` + (l ? ` ${l}` : "");
|
|
1764
|
+
return /* @__PURE__ */ b("div", { ref: v, className: g, style: y, children: [
|
|
1765
|
+
a && /* @__PURE__ */ c("span", { className: "nice-price-tag__prefix", children: a }),
|
|
1766
|
+
/* @__PURE__ */ b("span", { className: "nice-price-tag__main", children: [
|
|
1767
|
+
/* @__PURE__ */ c("span", { className: "nice-price-tag__amount", children: ie(e, { locale: o }) }),
|
|
1768
|
+
n && /* @__PURE__ */ c("span", { className: "nice-price-tag__period", children: n })
|
|
1769
|
+
] }),
|
|
1770
|
+
u && r && /* @__PURE__ */ c(
|
|
1771
|
+
"span",
|
|
1772
|
+
{
|
|
1773
|
+
className: "nice-price-tag__original",
|
|
1774
|
+
"aria-label": f("priceTag.originalPrice", "Original price"),
|
|
1775
|
+
children: /* @__PURE__ */ c("s", { children: ie(r, { locale: o }) })
|
|
1776
|
+
}
|
|
1777
|
+
),
|
|
1778
|
+
u && d && m != null && m > 0 && /* @__PURE__ */ b("span", { className: "nice-price-tag__discount", "aria-label": `${m} percent off`, children: [
|
|
1779
|
+
"−",
|
|
1780
|
+
m,
|
|
1781
|
+
"%"
|
|
1782
|
+
] }),
|
|
1783
|
+
i && /* @__PURE__ */ c("span", { className: "nice-price-tag__suffix", children: i })
|
|
1784
|
+
] });
|
|
1860
1785
|
}
|
|
1861
|
-
)
|
|
1862
|
-
|
|
1786
|
+
), jt = { amount: 0, currency: "USD" }, br = /* @__PURE__ */ se(function({
|
|
1787
|
+
source: e,
|
|
1788
|
+
defaultSource: r,
|
|
1789
|
+
onSourceChange: n,
|
|
1790
|
+
targetCurrency: a,
|
|
1791
|
+
defaultTargetCurrency: i,
|
|
1792
|
+
onTargetCurrencyChange: d,
|
|
1793
|
+
provider: s,
|
|
1794
|
+
locale: o,
|
|
1795
|
+
showRateLine: l = !0,
|
|
1796
|
+
className: y,
|
|
1797
|
+
style: v
|
|
1798
|
+
}, f) {
|
|
1799
|
+
const { t: u } = pe(), [m, g] = Pe({
|
|
1800
|
+
value: e,
|
|
1801
|
+
defaultValue: r,
|
|
1802
|
+
fallbackValue: jt,
|
|
1803
|
+
onChange: n,
|
|
1804
|
+
componentName: "NiceCurrencyConverter"
|
|
1805
|
+
}), [N, p] = Pe({
|
|
1806
|
+
value: a,
|
|
1807
|
+
defaultValue: i,
|
|
1808
|
+
fallbackValue: m.currency,
|
|
1809
|
+
onChange: d,
|
|
1810
|
+
componentName: "NiceCurrencyConverter"
|
|
1811
|
+
}), { converted: D, loading: _, error: w } = Se(m, N, s), U = K(
|
|
1812
|
+
() => ({ amount: Math.pow(10, 2), currency: m.currency }),
|
|
1813
|
+
[m.currency]
|
|
1814
|
+
), { converted: G } = Se(
|
|
1815
|
+
l ? U : null,
|
|
1816
|
+
N,
|
|
1817
|
+
s
|
|
1818
|
+
);
|
|
1819
|
+
return /* @__PURE__ */ b(
|
|
1820
|
+
"div",
|
|
1821
|
+
{
|
|
1822
|
+
ref: f,
|
|
1823
|
+
className: "nice-currency-converter" + (y ? ` ${y}` : ""),
|
|
1824
|
+
style: v,
|
|
1825
|
+
children: [
|
|
1826
|
+
/* @__PURE__ */ c("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ c(
|
|
1827
|
+
Ze,
|
|
1828
|
+
{
|
|
1829
|
+
label: u("currencyConverter.from", "From"),
|
|
1830
|
+
value: m,
|
|
1831
|
+
onChange: (M) => M && g(M),
|
|
1832
|
+
currency: m.currency,
|
|
1833
|
+
onCurrencyChange: (M) => g({ ...m, currency: M }),
|
|
1834
|
+
showFormattedPreview: !1
|
|
1835
|
+
}
|
|
1836
|
+
) }),
|
|
1837
|
+
/* @__PURE__ */ b("div", { className: "nice-currency-converter__row", children: [
|
|
1838
|
+
/* @__PURE__ */ c("label", { className: "nice-currency-converter__label", children: "To" }),
|
|
1839
|
+
/* @__PURE__ */ b("div", { className: "nice-currency-converter__output", children: [
|
|
1840
|
+
/* @__PURE__ */ c(
|
|
1841
|
+
Ge,
|
|
1842
|
+
{
|
|
1843
|
+
value: N,
|
|
1844
|
+
onChange: (M) => p(M),
|
|
1845
|
+
compact: !0
|
|
1846
|
+
}
|
|
1847
|
+
),
|
|
1848
|
+
/* @__PURE__ */ c("span", { className: "nice-currency-converter__amount", children: _ ? "…" : w ? "—" : D ? ie(D, { locale: o }) : "" })
|
|
1849
|
+
] })
|
|
1850
|
+
] }),
|
|
1851
|
+
l && G && /* @__PURE__ */ b("p", { className: "nice-currency-converter__rate", children: [
|
|
1852
|
+
"1 ",
|
|
1853
|
+
m.currency,
|
|
1854
|
+
" = ",
|
|
1855
|
+
ie(G, { locale: o }),
|
|
1856
|
+
" ",
|
|
1857
|
+
/* @__PURE__ */ b("span", { className: "nice-currency-converter__inverse", children: [
|
|
1858
|
+
"· 1 ",
|
|
1859
|
+
N,
|
|
1860
|
+
" =",
|
|
1861
|
+
" ",
|
|
1862
|
+
ie(ae(1 / He(G), m.currency), { locale: o })
|
|
1863
|
+
] })
|
|
1864
|
+
] }),
|
|
1865
|
+
w && /* @__PURE__ */ c("p", { className: "nice-currency-converter__error", role: "alert", children: w.message })
|
|
1866
|
+
]
|
|
1867
|
+
}
|
|
1868
|
+
);
|
|
1869
|
+
}), Yt = [];
|
|
1870
|
+
function Be(t) {
|
|
1863
1871
|
return { amount: Math.round(t.amount), currency: t.currency };
|
|
1864
1872
|
}
|
|
1865
|
-
const
|
|
1873
|
+
const fr = /* @__PURE__ */ se(
|
|
1866
1874
|
function({
|
|
1867
|
-
lines: e,
|
|
1875
|
+
lines: e = Yt,
|
|
1868
1876
|
locale: r,
|
|
1869
|
-
rounding:
|
|
1870
|
-
showTotals:
|
|
1877
|
+
rounding: n = "line",
|
|
1878
|
+
showTotals: a = !0,
|
|
1871
1879
|
showGrandTotal: i = !0,
|
|
1872
|
-
hideRateColumn:
|
|
1880
|
+
hideRateColumn: d = !1,
|
|
1873
1881
|
labels: s,
|
|
1874
1882
|
density: o = "comfortable",
|
|
1875
1883
|
className: l,
|
|
1876
|
-
style:
|
|
1884
|
+
style: y,
|
|
1877
1885
|
id: v
|
|
1878
|
-
},
|
|
1879
|
-
const
|
|
1886
|
+
}, f) {
|
|
1887
|
+
const u = {
|
|
1880
1888
|
label: (s == null ? void 0 : s.label) ?? "Item",
|
|
1881
1889
|
rate: (s == null ? void 0 : s.rate) ?? "VAT",
|
|
1882
1890
|
net: (s == null ? void 0 : s.net) ?? "Net",
|
|
1883
1891
|
vat: (s == null ? void 0 : s.vat) ?? "Tax",
|
|
1884
1892
|
gross: (s == null ? void 0 : s.gross) ?? "Gross",
|
|
1885
1893
|
total: (s == null ? void 0 : s.total) ?? "Total"
|
|
1886
|
-
},
|
|
1887
|
-
if (
|
|
1888
|
-
const
|
|
1889
|
-
for (const
|
|
1890
|
-
let
|
|
1891
|
-
|
|
1894
|
+
}, m = K(() => {
|
|
1895
|
+
if (n === "total") {
|
|
1896
|
+
const p = /* @__PURE__ */ new Map();
|
|
1897
|
+
for (const _ of e) {
|
|
1898
|
+
let w = p.get(_.vatRate);
|
|
1899
|
+
w || (w = [], p.set(_.vatRate, w)), w.push(_.netAmount);
|
|
1892
1900
|
}
|
|
1893
|
-
const
|
|
1894
|
-
for (const [
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1901
|
+
const D = [];
|
|
1902
|
+
for (const [_, w] of p) {
|
|
1903
|
+
const U = w.reduce((S, $) => ye(S, $), ae(0, w[0].currency)), G = Be(Ie(U, _)), M = ye(U, G);
|
|
1904
|
+
D.push({ rate: _, net: U, vat: G, gross: M });
|
|
1897
1905
|
}
|
|
1898
|
-
return
|
|
1906
|
+
return D;
|
|
1899
1907
|
}
|
|
1900
|
-
return e.map((
|
|
1901
|
-
const
|
|
1902
|
-
return { label:
|
|
1908
|
+
return e.map((p) => {
|
|
1909
|
+
const D = Be(Ie(p.netAmount, p.vatRate)), _ = ye(p.netAmount, D);
|
|
1910
|
+
return { label: p.label, rate: p.vatRate, net: p.netAmount, vat: D, gross: _ };
|
|
1903
1911
|
});
|
|
1904
|
-
}, [e,
|
|
1905
|
-
if (
|
|
1912
|
+
}, [e, n]), g = K(() => {
|
|
1913
|
+
if (m.length === 0)
|
|
1906
1914
|
return null;
|
|
1907
|
-
const
|
|
1908
|
-
let
|
|
1909
|
-
for (const
|
|
1910
|
-
|
|
1911
|
-
return { net:
|
|
1912
|
-
}, [
|
|
1913
|
-
return /* @__PURE__ */
|
|
1915
|
+
const p = m[0].net.currency;
|
|
1916
|
+
let D = ae(0, p), _ = ae(0, p), w = ae(0, p);
|
|
1917
|
+
for (const U of m)
|
|
1918
|
+
D = ye(D, U.net), _ = ye(_, U.vat), w = ye(w, U.gross);
|
|
1919
|
+
return { net: D, vat: _, gross: w };
|
|
1920
|
+
}, [m]), N = (p) => ie(p, { locale: r });
|
|
1921
|
+
return /* @__PURE__ */ b(
|
|
1914
1922
|
"table",
|
|
1915
1923
|
{
|
|
1916
|
-
ref:
|
|
1924
|
+
ref: f,
|
|
1917
1925
|
id: v,
|
|
1918
1926
|
className: `nice-tax-breakdown nice-tax-breakdown--${o} ${l ?? ""}`,
|
|
1919
|
-
style:
|
|
1927
|
+
style: y,
|
|
1920
1928
|
role: "table",
|
|
1921
|
-
"aria-label":
|
|
1929
|
+
"aria-label": u.total,
|
|
1922
1930
|
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:
|
|
1931
|
+
/* @__PURE__ */ c("thead", { children: /* @__PURE__ */ b("tr", { children: [
|
|
1932
|
+
m.some((p) => p.label !== void 0) && /* @__PURE__ */ c("th", { scope: "col", children: u.label }),
|
|
1933
|
+
!d && /* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__rate", children: u.rate }),
|
|
1934
|
+
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: u.net }),
|
|
1935
|
+
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: u.vat }),
|
|
1936
|
+
/* @__PURE__ */ c("th", { scope: "col", className: "nice-tax-breakdown__num", children: u.gross })
|
|
1929
1937
|
] }) }),
|
|
1930
|
-
/* @__PURE__ */ c("tbody", { children:
|
|
1931
|
-
|
|
1932
|
-
!
|
|
1933
|
-
(
|
|
1938
|
+
/* @__PURE__ */ c("tbody", { children: m.map((p, D) => /* @__PURE__ */ b("tr", { children: [
|
|
1939
|
+
m.some((_) => _.label !== void 0) && /* @__PURE__ */ c("td", { children: p.label ?? "" }),
|
|
1940
|
+
!d && /* @__PURE__ */ b("td", { className: "nice-tax-breakdown__rate", children: [
|
|
1941
|
+
(p.rate * 100).toLocaleString(r, { maximumFractionDigits: 2 }),
|
|
1934
1942
|
"%"
|
|
1935
1943
|
] }),
|
|
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: g
|
|
1944
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: g
|
|
1945
|
-
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: g
|
|
1944
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: N(p.net) }),
|
|
1945
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: N(p.vat) }),
|
|
1946
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: N(p.gross) })
|
|
1947
|
+
] }, `${p.rate}-${D}`)) }),
|
|
1948
|
+
a && g && /* @__PURE__ */ c("tfoot", { children: i && /* @__PURE__ */ b("tr", { className: "nice-tax-breakdown__totals", children: [
|
|
1949
|
+
m.some((p) => p.label !== void 0) && /* @__PURE__ */ c("td", { children: u.total }),
|
|
1950
|
+
!d && /* @__PURE__ */ c("td", { children: m.some((p) => p.label !== void 0) ? null : u.total }),
|
|
1951
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: N(g.net) }),
|
|
1952
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: N(g.vat) }),
|
|
1953
|
+
/* @__PURE__ */ c("td", { className: "nice-tax-breakdown__num", children: N(g.gross) })
|
|
1946
1954
|
] }) })
|
|
1947
1955
|
]
|
|
1948
1956
|
}
|
|
1949
1957
|
);
|
|
1950
1958
|
}
|
|
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 = [
|
|
1959
|
+
), Gt = [], _r = /* @__PURE__ */ se(function(e, r) {
|
|
1960
|
+
const { t: n } = pe(), {
|
|
1961
|
+
methods: a = Gt,
|
|
1962
|
+
value: i,
|
|
1963
|
+
onChange: d,
|
|
1964
|
+
layout: s = "list",
|
|
1965
|
+
columns: o = 2,
|
|
1966
|
+
currency: l,
|
|
1967
|
+
label: y,
|
|
1968
|
+
name: v,
|
|
1969
|
+
readOnly: f = !1,
|
|
1970
|
+
className: u,
|
|
1971
|
+
style: m,
|
|
1972
|
+
id: g,
|
|
1973
|
+
accessMode: N,
|
|
1974
|
+
"data-testid": p
|
|
1975
|
+
} = e, D = _e(), _ = v ?? `nice-pm-${D}`, w = K(() => {
|
|
1976
|
+
if (!l)
|
|
1977
|
+
return a;
|
|
1978
|
+
const S = l.toUpperCase();
|
|
1979
|
+
return a.filter(
|
|
1980
|
+
($) => !$.currencies || $.currencies.map((A) => A.toUpperCase()).includes(S)
|
|
1981
|
+
);
|
|
1982
|
+
}, [a, l]);
|
|
1983
|
+
if (N === "hidden")
|
|
1984
|
+
return null;
|
|
1985
|
+
const U = f || N === "disabled" || N === "readOnly", G = `nice-payment-method-selector nice-payment-method-selector--${s}` + (u ? ` ${u}` : ""), M = s === "grid" ? { gridTemplateColumns: `repeat(${o}, minmax(0, 1fr))` } : void 0;
|
|
1986
|
+
return /* @__PURE__ */ b("div", { ref: r, id: g, className: G, style: m, "data-testid": p, children: [
|
|
1987
|
+
y && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__label", children: y }),
|
|
1988
|
+
/* @__PURE__ */ b(
|
|
1989
|
+
"div",
|
|
1990
|
+
{
|
|
1991
|
+
className: "nice-payment-method-selector__options",
|
|
1992
|
+
style: M,
|
|
1993
|
+
role: "radiogroup",
|
|
1994
|
+
"aria-label": y ?? "Payment method",
|
|
1995
|
+
children: [
|
|
1996
|
+
w.map((S) => {
|
|
1997
|
+
const $ = S.id === i, A = U || S.disabled;
|
|
1998
|
+
return /* @__PURE__ */ b(
|
|
1999
|
+
"label",
|
|
2000
|
+
{
|
|
2001
|
+
className: "nice-payment-method-selector__option" + ($ ? " nice-payment-method-selector__option--selected" : "") + (A ? " nice-payment-method-selector__option--disabled" : ""),
|
|
2002
|
+
children: [
|
|
2003
|
+
/* @__PURE__ */ c(
|
|
2004
|
+
"input",
|
|
2005
|
+
{
|
|
2006
|
+
type: "radio",
|
|
2007
|
+
className: "nice-payment-method-selector__radio",
|
|
2008
|
+
name: _,
|
|
2009
|
+
value: S.id,
|
|
2010
|
+
checked: $,
|
|
2011
|
+
disabled: A,
|
|
2012
|
+
onChange: () => d == null ? void 0 : d(S.id)
|
|
2013
|
+
}
|
|
2014
|
+
),
|
|
2015
|
+
S.icon && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__icon", children: S.icon }),
|
|
2016
|
+
/* @__PURE__ */ b("span", { className: "nice-payment-method-selector__text", children: [
|
|
2017
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-method-selector__name", children: S.label }),
|
|
2018
|
+
S.description && /* @__PURE__ */ c("span", { className: "nice-payment-method-selector__desc", children: S.description })
|
|
2019
|
+
] })
|
|
2020
|
+
]
|
|
2021
|
+
},
|
|
2022
|
+
S.id
|
|
2023
|
+
);
|
|
2024
|
+
}),
|
|
2025
|
+
w.length === 0 && /* @__PURE__ */ c("div", { className: "nice-payment-method-selector__empty", children: n("paymentMethodSelector.noMethodsAvailable", "No methods available.") })
|
|
2026
|
+
]
|
|
2027
|
+
}
|
|
2028
|
+
)
|
|
2029
|
+
] });
|
|
2030
|
+
}), Zt = [
|
|
2025
2031
|
{
|
|
2026
2032
|
target: ".nice-payment-provider-config",
|
|
2027
2033
|
titleKey: "tutorial.paymentProviderConfig.intro.title",
|
|
@@ -2030,258 +2036,264 @@ const pr = ie(
|
|
|
2030
2036
|
content: "Pick a provider, fill its credentials (secrets are masked), choose test/live, enable methods and copy the webhook URL.",
|
|
2031
2037
|
placement: "auto"
|
|
2032
2038
|
}
|
|
2033
|
-
],
|
|
2039
|
+
], Jt = {
|
|
2034
2040
|
providerId: "",
|
|
2035
2041
|
mode: "test",
|
|
2036
2042
|
credentials: {},
|
|
2037
2043
|
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
|
-
}
|
|
2044
|
+
}, gr = /* @__PURE__ */ se(function(e, r) {
|
|
2045
|
+
const { t: n } = pe(), {
|
|
2046
|
+
value: a,
|
|
2047
|
+
defaultValue: i,
|
|
2048
|
+
onChange: d,
|
|
2049
|
+
providers: s,
|
|
2050
|
+
onTestConnection: o,
|
|
2051
|
+
showWebhookUrl: l = !0,
|
|
2052
|
+
baseUrl: y,
|
|
2053
|
+
readOnly: v = !1,
|
|
2054
|
+
testLabel: f = "Test connection",
|
|
2055
|
+
tutorial: u,
|
|
2056
|
+
className: m,
|
|
2057
|
+
style: g,
|
|
2058
|
+
id: N,
|
|
2059
|
+
accessMode: p,
|
|
2060
|
+
"data-testid": D
|
|
2061
|
+
} = e, [_, w] = Pe({
|
|
2062
|
+
value: a,
|
|
2063
|
+
defaultValue: i,
|
|
2064
|
+
fallbackValue: Jt,
|
|
2065
|
+
onChange: d,
|
|
2066
|
+
componentName: "NicePaymentProviderConfig"
|
|
2067
|
+
}), U = _e(), [G, M] = z(/* @__PURE__ */ new Set()), [S, $] = z(!1), [A, W] = z(null), O = K(() => s ? s.map((h) => we[h]).filter((h) => !!h) : Kt, [s]), k = we[_.providerId];
|
|
2068
|
+
if (p === "hidden")
|
|
2069
|
+
return null;
|
|
2070
|
+
const B = v || p === "disabled" || p === "readOnly", F = (h) => {
|
|
2071
|
+
W(null), M(/* @__PURE__ */ new Set()), w({ providerId: h, mode: _.mode, credentials: {}, enabledMethods: [] });
|
|
2072
|
+
}, Q = (h, q) => {
|
|
2073
|
+
w({ ..._, credentials: { ..._.credentials, [h]: q } });
|
|
2074
|
+
}, ce = (h) => {
|
|
2075
|
+
const q = new Set(_.enabledMethods ?? []);
|
|
2076
|
+
q.has(h) ? q.delete(h) : q.add(h), w({ ..._, enabledMethods: [...q] });
|
|
2077
|
+
}, H = (h) => {
|
|
2078
|
+
M((q) => {
|
|
2079
|
+
const j = new Set(q);
|
|
2080
|
+
return j.has(h) ? j.delete(h) : j.add(h), j;
|
|
2081
|
+
});
|
|
2082
|
+
}, te = async () => {
|
|
2083
|
+
if (o) {
|
|
2084
|
+
$(!0), W(null);
|
|
2085
|
+
try {
|
|
2086
|
+
W(await o(_));
|
|
2087
|
+
} catch (h) {
|
|
2088
|
+
W({ ok: !1, message: h instanceof Error ? h.message : String(h) });
|
|
2089
|
+
} finally {
|
|
2090
|
+
$(!1);
|
|
2087
2091
|
}
|
|
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
|
-
] })
|
|
2092
|
+
}
|
|
2093
|
+
}, J = k != null && k.webhookPath ? `${(y ?? "").replace(/\/$/, "")}${k.webhookPath}` : "", T = (k == null ? void 0 : k.supportedCurrencies) === "*" ? "All currencies" : ((k == null ? void 0 : k.supportedCurrencies) ?? []).join(", "), E = "nice-payment-provider-config" + (m ? ` ${m}` : ""), P = ((k == null ? void 0 : k.credentials) ?? []).filter(
|
|
2094
|
+
(h) => !h.testOnly || _.mode === "test"
|
|
2095
|
+
);
|
|
2096
|
+
return /* @__PURE__ */ b("div", { ref: r, id: N, className: E, style: g, "data-testid": D, children: [
|
|
2097
|
+
u && /* @__PURE__ */ c("div", { className: "nice-payment-provider-config__tutorial", children: /* @__PURE__ */ c(st, { steps: ot(u, Zt) }) }),
|
|
2098
|
+
/* @__PURE__ */ b("div", { className: "nice-payment-provider-config__row", children: [
|
|
2099
|
+
/* @__PURE__ */ b("label", { className: "nice-payment-provider-config__field", children: [
|
|
2100
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: n("paymentProviderConfig.provider", "Provider") }),
|
|
2101
|
+
/* @__PURE__ */ b(
|
|
2102
|
+
"select",
|
|
2103
|
+
{
|
|
2104
|
+
className: "nice-payment-provider-config__select",
|
|
2105
|
+
value: _.providerId,
|
|
2106
|
+
disabled: B,
|
|
2107
|
+
onChange: (h) => F(h.target.value),
|
|
2108
|
+
children: [
|
|
2109
|
+
/* @__PURE__ */ c("option", { value: "", children: "— select provider —" }),
|
|
2110
|
+
O.map((h) => /* @__PURE__ */ c("option", { value: h.id, children: h.name }, h.id))
|
|
2111
|
+
]
|
|
2112
|
+
}
|
|
2113
|
+
)
|
|
2132
2114
|
] }),
|
|
2133
|
-
k && /* @__PURE__ */
|
|
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
|
-
|
|
2115
|
+
(k == null ? void 0 : k.hasTestMode) && /* @__PURE__ */ b(
|
|
2116
|
+
"div",
|
|
2117
|
+
{
|
|
2118
|
+
className: "nice-payment-provider-config__mode",
|
|
2119
|
+
role: "group",
|
|
2120
|
+
"aria-label": n("paymentProviderConfig.mode", "Mode"),
|
|
2121
|
+
children: [
|
|
2122
|
+
/* @__PURE__ */ c(
|
|
2123
|
+
"button",
|
|
2124
|
+
{
|
|
2125
|
+
type: "button",
|
|
2126
|
+
className: "nice-payment-provider-config__mode-btn" + (_.mode === "test" ? " nice-payment-provider-config__mode-btn--active" : ""),
|
|
2127
|
+
onClick: () => w({ ..._, mode: "test" }),
|
|
2128
|
+
disabled: B,
|
|
2129
|
+
children: n("paymentProviderConfig.test", "Test")
|
|
2130
|
+
}
|
|
2131
|
+
),
|
|
2132
|
+
/* @__PURE__ */ c(
|
|
2133
|
+
"button",
|
|
2134
|
+
{
|
|
2135
|
+
type: "button",
|
|
2136
|
+
className: "nice-payment-provider-config__mode-btn" + (_.mode === "live" ? " nice-payment-provider-config__mode-btn--active" : ""),
|
|
2137
|
+
onClick: () => w({ ..._, mode: "live" }),
|
|
2138
|
+
disabled: B,
|
|
2139
|
+
children: n("paymentProviderConfig.live", "Live")
|
|
2140
|
+
}
|
|
2141
|
+
)
|
|
2142
|
+
]
|
|
2143
|
+
}
|
|
2144
|
+
)
|
|
2145
|
+
] }),
|
|
2146
|
+
k && /* @__PURE__ */ b(it, { children: [
|
|
2147
|
+
/* @__PURE__ */ b("div", { className: "nice-payment-provider-config__meta", children: [
|
|
2148
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__badge", children: k.type }),
|
|
2149
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__currencies", children: T })
|
|
2150
|
+
] }),
|
|
2151
|
+
/* @__PURE__ */ c("div", { className: "nice-payment-provider-config__credentials", children: P.map((h) => {
|
|
2152
|
+
const q = `${U}-${h.key}`, j = h.secret, C = G.has(h.key);
|
|
2153
|
+
return /* @__PURE__ */ b("div", { className: "nice-payment-provider-config__field", children: [
|
|
2154
|
+
/* @__PURE__ */ b("label", { className: "nice-payment-provider-config__field-label", htmlFor: q, children: [
|
|
2155
|
+
h.label,
|
|
2156
|
+
h.required && /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__required", children: " *" })
|
|
2157
|
+
] }),
|
|
2158
|
+
/* @__PURE__ */ b("div", { className: "nice-payment-provider-config__input-wrap", children: [
|
|
2176
2159
|
/* @__PURE__ */ c(
|
|
2177
2160
|
"input",
|
|
2178
2161
|
{
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2162
|
+
id: q,
|
|
2163
|
+
type: j && !C ? "password" : "text",
|
|
2164
|
+
className: "nice-payment-provider-config__input",
|
|
2165
|
+
value: _.credentials[h.key] ?? "",
|
|
2166
|
+
readOnly: B,
|
|
2167
|
+
autoComplete: j ? "new-password" : "off",
|
|
2168
|
+
onChange: (L) => Q(h.key, L.target.value)
|
|
2183
2169
|
}
|
|
2184
2170
|
),
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2171
|
+
j && /* @__PURE__ */ c(
|
|
2172
|
+
"button",
|
|
2173
|
+
{
|
|
2174
|
+
type: "button",
|
|
2175
|
+
className: "nice-payment-provider-config__reveal",
|
|
2176
|
+
onClick: () => H(h.key),
|
|
2177
|
+
"aria-label": C ? "Hide" : "Reveal",
|
|
2178
|
+
"aria-pressed": C,
|
|
2179
|
+
children: /* @__PURE__ */ c(Me, { name: C ? "eye-off" : "eye", size: 14 })
|
|
2180
|
+
}
|
|
2181
|
+
)
|
|
2182
|
+
] }),
|
|
2183
|
+
h.help && /* @__PURE__ */ c("span", { className: "nice-payment-provider-config__help", children: h.help })
|
|
2184
|
+
] }, h.key);
|
|
2185
|
+
}) }),
|
|
2186
|
+
k.supportedMethods && k.supportedMethods.length > 0 && /* @__PURE__ */ b("div", { className: "nice-payment-provider-config__methods", children: [
|
|
2187
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: n("paymentProviderConfig.enabledMethods", "Enabled methods") }),
|
|
2188
|
+
/* @__PURE__ */ c("div", { className: "nice-payment-provider-config__method-list", children: k.supportedMethods.map((h) => /* @__PURE__ */ b("label", { className: "nice-payment-provider-config__method", children: [
|
|
2193
2189
|
/* @__PURE__ */ c(
|
|
2194
|
-
"
|
|
2190
|
+
"input",
|
|
2195
2191
|
{
|
|
2196
|
-
type: "
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
children: I ? "Testing…" : v
|
|
2192
|
+
type: "checkbox",
|
|
2193
|
+
checked: (_.enabledMethods ?? []).includes(h),
|
|
2194
|
+
disabled: B,
|
|
2195
|
+
onChange: () => ce(h)
|
|
2201
2196
|
}
|
|
2202
2197
|
),
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2198
|
+
h
|
|
2199
|
+
] }, h)) })
|
|
2200
|
+
] }),
|
|
2201
|
+
l && k.webhookPath && /* @__PURE__ */ b("div", { className: "nice-payment-provider-config__field", children: [
|
|
2202
|
+
/* @__PURE__ */ c("span", { className: "nice-payment-provider-config__field-label", children: n("paymentProviderConfig.webhookUrl", "Webhook URL") }),
|
|
2203
|
+
/* @__PURE__ */ c("code", { className: "nice-payment-provider-config__webhook", children: J })
|
|
2204
|
+
] }),
|
|
2205
|
+
o && /* @__PURE__ */ b("div", { className: "nice-payment-provider-config__test", children: [
|
|
2206
|
+
/* @__PURE__ */ c(
|
|
2207
|
+
"button",
|
|
2208
|
+
{
|
|
2209
|
+
type: "button",
|
|
2210
|
+
className: "nice-payment-provider-config__test-btn",
|
|
2211
|
+
onClick: () => void te(),
|
|
2212
|
+
disabled: B || S,
|
|
2213
|
+
children: S ? "Testing…" : f
|
|
2214
|
+
}
|
|
2215
|
+
),
|
|
2216
|
+
A && /* @__PURE__ */ b(
|
|
2217
|
+
"span",
|
|
2218
|
+
{
|
|
2219
|
+
className: "nice-payment-provider-config__test-result nice-payment-provider-config__test-result--" + (A.ok ? "ok" : "error"),
|
|
2220
|
+
children: [
|
|
2221
|
+
/* @__PURE__ */ c(Me, { name: A.ok ? "check" : "close", size: 14 }),
|
|
2222
|
+
" ",
|
|
2223
|
+
A.message ?? (A.ok ? "OK" : "Failed")
|
|
2224
|
+
]
|
|
2225
|
+
}
|
|
2226
|
+
)
|
|
2215
2227
|
] })
|
|
2216
|
-
] })
|
|
2217
|
-
}
|
|
2218
|
-
);
|
|
2228
|
+
] })
|
|
2229
|
+
] });
|
|
2230
|
+
});
|
|
2219
2231
|
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
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2232
|
+
ft as EcbRatesProvider,
|
|
2233
|
+
ht as ExchangeRateHostProvider,
|
|
2234
|
+
pt as FrankfurterProvider,
|
|
2235
|
+
_t as FreeForexApiProvider,
|
|
2236
|
+
vt as MockPaymentProcessor,
|
|
2237
|
+
fe as NICE_CURRENCY_CATALOG,
|
|
2238
|
+
pr as NICE_CURRENCY_CODES,
|
|
2239
|
+
Et as NICE_PAYMENT_PROCESSORS,
|
|
2240
|
+
Kt as NICE_PAYMENT_PROVIDER_LIST,
|
|
2241
|
+
we as NICE_PAYMENT_PROVIDER_PROFILES,
|
|
2242
|
+
bt as NbpRatesProvider,
|
|
2243
|
+
Lt as NiceCreditCardInput,
|
|
2244
|
+
br as NiceCurrencyConverter,
|
|
2245
|
+
Ge as NiceCurrencySelector,
|
|
2246
|
+
Ke as NiceMoney,
|
|
2247
|
+
Ze as NiceMoneyInput,
|
|
2248
|
+
yr as NicePaymentForm,
|
|
2249
|
+
_r as NicePaymentMethodSelector,
|
|
2250
|
+
gr as NicePaymentProviderConfig,
|
|
2251
|
+
hr as NicePriceTag,
|
|
2252
|
+
fr as NiceTaxBreakdown,
|
|
2253
|
+
yt as OpenExchangeRatesProvider,
|
|
2254
|
+
ir as StaticExchangeRateProvider,
|
|
2255
|
+
ye as addMoney,
|
|
2256
|
+
tr as compareMoney,
|
|
2257
|
+
gt as convertMoney,
|
|
2258
|
+
or as createEcbRatesProvider,
|
|
2259
|
+
dr as createFreeForexApiProvider,
|
|
2260
|
+
sr as createNbpRatesProvider,
|
|
2261
|
+
lr as createOpenExchangeRatesProvider,
|
|
2262
|
+
ke as detectCardBrand,
|
|
2263
|
+
be as expectedCvcLength,
|
|
2264
|
+
ne as findCurrency,
|
|
2265
|
+
ur as findPaymentProviderProfile,
|
|
2266
|
+
mt as formatCardNumber,
|
|
2267
|
+
ie as formatMoney,
|
|
2268
|
+
He as fromMoney,
|
|
2269
|
+
Ye as isExpiryValid,
|
|
2270
|
+
nr as isNegative,
|
|
2271
|
+
rr as isZero,
|
|
2272
|
+
ze as luhnCheck,
|
|
2273
|
+
kt as makeAdyenAdapter,
|
|
2274
|
+
xt as makeAutopayAdapter,
|
|
2275
|
+
Rt as makeBlikAdapter,
|
|
2276
|
+
Mt as makeBraintreeAdapter,
|
|
2277
|
+
At as makeCoinbaseCommerceAdapter,
|
|
2278
|
+
Ut as makeKlarnaAdapter,
|
|
2279
|
+
Dt as makeMollieAdapter,
|
|
2280
|
+
wt as makePayPalAdapter,
|
|
2281
|
+
It as makePayUAdapter,
|
|
2282
|
+
St as makePrzelewy24Adapter,
|
|
2283
|
+
Pt as makeRazorpayAdapter,
|
|
2284
|
+
Ct as makeSquareAdapter,
|
|
2285
|
+
Nt as makeStripeAdapter,
|
|
2286
|
+
$t as makeTpayAdapter,
|
|
2287
|
+
cr as maskCardNumber,
|
|
2288
|
+
Ie as multiplyMoney,
|
|
2289
|
+
ar as negateMoney,
|
|
2290
|
+
je as normaliseExpiry,
|
|
2291
|
+
ut as parseMoney,
|
|
2292
|
+
er as registerCurrency,
|
|
2293
|
+
dt as subtractMoney,
|
|
2294
|
+
ae as toMoney,
|
|
2295
|
+
Se as useNiceExchangeRate,
|
|
2296
|
+
mr as useNiceMoney,
|
|
2297
|
+
Ot as useNicePayment,
|
|
2298
|
+
qe as validateCreditCard
|
|
2287
2299
|
};
|