@nice2dev/ui-money 1.0.10 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/NiceMoneyInput.d.ts +15 -0
- package/dist/components/NiceTaxBreakdown.d.ts +46 -0
- package/dist/exchange.d.ts +39 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.mjs +939 -755
- package/dist/processors.d.ts +23 -0
- package/dist/style.css +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import { jsxs as N, jsx as
|
|
6
|
-
const
|
|
1
|
+
var Xe = Object.defineProperty;
|
|
2
|
+
var Qe = (t, e, n) => e in t ? Xe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var K = (t, e, n) => Qe(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import Ve, { useState as B, useRef as We, useEffect as et, useMemo as k, useCallback as F, forwardRef as de, useId as Ce } from "react";
|
|
5
|
+
import { jsxs as N, jsx as s } from "react/jsx-runtime";
|
|
6
|
+
const fe = [
|
|
7
7
|
// ── Majors ─────────────────────────────────────
|
|
8
8
|
{ code: "USD", numeric: 840, symbol: "$", name: "US Dollar", decimals: 2, symbolFirst: !0 },
|
|
9
9
|
{ code: "EUR", numeric: 978, symbol: "€", name: "Euro", decimals: 2, symbolFirst: !0 },
|
|
@@ -225,186 +225,186 @@ const se = [
|
|
|
225
225
|
{ code: "ETH", numeric: 0, symbol: "Ξ", name: "Ether", decimals: 8, symbolFirst: !0 },
|
|
226
226
|
{ code: "USDC", numeric: 0, symbol: "USDC", name: "USD Coin", decimals: 6 },
|
|
227
227
|
{ code: "USDT", numeric: 0, symbol: "USDT", name: "Tether", decimals: 6 }
|
|
228
|
-
],
|
|
229
|
-
function
|
|
230
|
-
return
|
|
228
|
+
], Oe = new Map(fe.map((t) => [t.code, t]));
|
|
229
|
+
function V(t) {
|
|
230
|
+
return Oe.get(t.toUpperCase());
|
|
231
231
|
}
|
|
232
|
-
function
|
|
233
|
-
|
|
234
|
-
const e =
|
|
235
|
-
e >= 0 ?
|
|
232
|
+
function Et(t) {
|
|
233
|
+
Oe.set(t.code.toUpperCase(), t);
|
|
234
|
+
const e = fe.findIndex((n) => n.code === t.code);
|
|
235
|
+
e >= 0 ? fe[e] = t : fe.push(t);
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
const n =
|
|
239
|
-
return { amount: (
|
|
237
|
+
function W(t, e) {
|
|
238
|
+
const n = V(e), c = (n == null ? void 0 : n.decimals) ?? 2, r = Math.pow(10, c);
|
|
239
|
+
return { amount: (t < 0 ? -1 : 1) * Math.round(Math.abs(t) * r), currency: e.toUpperCase() };
|
|
240
240
|
}
|
|
241
|
-
function
|
|
242
|
-
const e =
|
|
243
|
-
return
|
|
241
|
+
function Ke(t) {
|
|
242
|
+
const e = V(t.currency), n = (e == null ? void 0 : e.decimals) ?? 2;
|
|
243
|
+
return t.amount / Math.pow(10, n);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
246
|
-
return
|
|
245
|
+
function tt(t, e) {
|
|
246
|
+
return t.currency.toUpperCase() === e.currency.toUpperCase();
|
|
247
247
|
}
|
|
248
|
-
function
|
|
249
|
-
if (!
|
|
250
|
-
throw new Error(`Cannot ${n} different currencies: ${
|
|
248
|
+
function $e(t, e, n) {
|
|
249
|
+
if (!tt(t, e))
|
|
250
|
+
throw new Error(`Cannot ${n} different currencies: ${t.currency} vs ${e.currency}`);
|
|
251
251
|
}
|
|
252
|
-
function
|
|
253
|
-
return
|
|
252
|
+
function me(t, e) {
|
|
253
|
+
return $e(t, e, "add"), { amount: t.amount + e.amount, currency: t.currency };
|
|
254
254
|
}
|
|
255
|
-
function
|
|
256
|
-
return
|
|
255
|
+
function nt(t, e) {
|
|
256
|
+
return $e(t, e, "subtract"), { amount: t.amount - e.amount, currency: t.currency };
|
|
257
257
|
}
|
|
258
|
-
function
|
|
258
|
+
function De(t, e) {
|
|
259
259
|
return {
|
|
260
|
-
amount: (
|
|
261
|
-
currency:
|
|
260
|
+
amount: (t.amount * e < 0 ? -1 : 1) * Math.round(Math.abs(t.amount * e)),
|
|
261
|
+
currency: t.currency
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
|
-
function
|
|
265
|
-
return
|
|
264
|
+
function At(t, e) {
|
|
265
|
+
return $e(t, e, "compare"), t.amount - e.amount;
|
|
266
266
|
}
|
|
267
|
-
function
|
|
268
|
-
return
|
|
267
|
+
function Ot(t) {
|
|
268
|
+
return t.amount === 0;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
return
|
|
270
|
+
function Kt(t) {
|
|
271
|
+
return t.amount < 0;
|
|
272
272
|
}
|
|
273
|
-
function
|
|
274
|
-
return { amount: -
|
|
273
|
+
function Bt(t) {
|
|
274
|
+
return { amount: -t.amount, currency: t.currency };
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
const n =
|
|
276
|
+
function te(t, e = {}) {
|
|
277
|
+
const n = V(t.currency), c = e.decimals ?? (n == null ? void 0 : n.decimals) ?? 2, r = t.amount / Math.pow(10, c);
|
|
278
278
|
try {
|
|
279
279
|
return new Intl.NumberFormat(e.locale, {
|
|
280
280
|
style: "currency",
|
|
281
|
-
currency:
|
|
282
|
-
minimumFractionDigits:
|
|
283
|
-
maximumFractionDigits:
|
|
281
|
+
currency: t.currency,
|
|
282
|
+
minimumFractionDigits: c,
|
|
283
|
+
maximumFractionDigits: c,
|
|
284
284
|
currencyDisplay: e.currencyDisplay ?? "symbol"
|
|
285
|
-
}).format(
|
|
285
|
+
}).format(r);
|
|
286
286
|
} catch {
|
|
287
|
-
const a = (n == null ? void 0 : n.symbol) ??
|
|
287
|
+
const a = (n == null ? void 0 : n.symbol) ?? t.currency, o = r.toFixed(c);
|
|
288
288
|
return n != null && n.symbolFirst ? `${a}${o}` : `${o} ${a}`;
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
|
-
function
|
|
292
|
-
if (!
|
|
291
|
+
function rt(t, e) {
|
|
292
|
+
if (!t)
|
|
293
293
|
return null;
|
|
294
|
-
let n =
|
|
294
|
+
let n = t.replace(/[^\d.,\-]/g, "").trim();
|
|
295
295
|
if (!n || n === "-")
|
|
296
296
|
return null;
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
const
|
|
300
|
-
let
|
|
301
|
-
o === -1 ?
|
|
302
|
-
const
|
|
303
|
-
return Number.isFinite(
|
|
297
|
+
const c = n.startsWith("-");
|
|
298
|
+
c && (n = n.slice(1));
|
|
299
|
+
const r = n.lastIndexOf("."), a = n.lastIndexOf(","), o = Math.max(r, a);
|
|
300
|
+
let i, l = "";
|
|
301
|
+
o === -1 ? i = n : (i = n.slice(0, o).replace(/[.,]/g, ""), l = n.slice(o + 1).replace(/[.,]/g, ""));
|
|
302
|
+
const u = `${i}.${l || "0"}`, m = parseFloat(u);
|
|
303
|
+
return Number.isFinite(m) ? W(c ? -m : m, e) : null;
|
|
304
304
|
}
|
|
305
|
-
function
|
|
306
|
-
const e = (
|
|
305
|
+
function Ne(t) {
|
|
306
|
+
const e = (t || "").replace(/\D/g, "");
|
|
307
307
|
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";
|
|
308
308
|
}
|
|
309
|
-
function
|
|
310
|
-
const e = (
|
|
309
|
+
function Be(t) {
|
|
310
|
+
const e = (t || "").replace(/\D/g, "");
|
|
311
311
|
if (e.length < 12 || e.length > 19)
|
|
312
312
|
return !1;
|
|
313
|
-
let n = 0,
|
|
314
|
-
for (let
|
|
315
|
-
let a = e.charCodeAt(
|
|
316
|
-
|
|
313
|
+
let n = 0, c = !1;
|
|
314
|
+
for (let r = e.length - 1; r >= 0; r--) {
|
|
315
|
+
let a = e.charCodeAt(r) - 48;
|
|
316
|
+
c && (a *= 2, a > 9 && (a -= 9)), n += a, c = !c;
|
|
317
317
|
}
|
|
318
318
|
return n % 10 === 0;
|
|
319
319
|
}
|
|
320
|
-
function
|
|
321
|
-
const n = (
|
|
322
|
-
return
|
|
320
|
+
function ct(t, e) {
|
|
321
|
+
const n = (t || "").replace(/\D/g, ""), c = e ?? Ne(n);
|
|
322
|
+
return c === "amex" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 15)].filter(Boolean).join(" ") : c === "diners" ? [n.slice(0, 4), n.slice(4, 10), n.slice(10, 14)].filter(Boolean).join(" ") : (n.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
323
323
|
}
|
|
324
|
-
function
|
|
325
|
-
const n = (
|
|
324
|
+
function Tt(t, e) {
|
|
325
|
+
const n = (t || "").replace(/\D/g, "");
|
|
326
326
|
if (n.length < 4)
|
|
327
327
|
return n;
|
|
328
|
-
const
|
|
329
|
-
return a === "amex" ? [
|
|
328
|
+
const c = n.slice(-4), r = "*".repeat(n.length - 4) + c, a = e ?? Ne(n);
|
|
329
|
+
return a === "amex" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 15)].filter(Boolean).join(" ") : a === "diners" ? [r.slice(0, 4), r.slice(4, 10), r.slice(10, 14)].filter(Boolean).join(" ") : (r.match(/.{1,4}/g) ?? []).join(" ").trim();
|
|
330
330
|
}
|
|
331
|
-
function
|
|
332
|
-
const e = (
|
|
331
|
+
function Te(t) {
|
|
332
|
+
const e = (t || "").replace(/\D/g, "");
|
|
333
333
|
if (e.length < 3)
|
|
334
334
|
return null;
|
|
335
|
-
const n = e.slice(0, 2),
|
|
336
|
-
return !Number.isFinite(
|
|
335
|
+
const n = e.slice(0, 2), c = e.length >= 4 ? e.slice(-2) : e.slice(2, 4), r = parseInt(n, 10);
|
|
336
|
+
return !Number.isFinite(r) || r < 1 || r > 12 ? null : `${n}/${c}`;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
339
|
-
const n =
|
|
338
|
+
function Le(t, e = /* @__PURE__ */ new Date()) {
|
|
339
|
+
const n = Te(t);
|
|
340
340
|
if (!n)
|
|
341
341
|
return !1;
|
|
342
|
-
const [
|
|
342
|
+
const [c, r] = n.split("/"), a = parseInt(c, 10), o = 2e3 + parseInt(r, 10);
|
|
343
343
|
return new Date(o, a, 0, 23, 59, 59, 999).getTime() >= e.getTime();
|
|
344
344
|
}
|
|
345
|
-
function
|
|
346
|
-
return
|
|
345
|
+
function ye(t) {
|
|
346
|
+
return t === "amex" ? 4 : 3;
|
|
347
347
|
}
|
|
348
|
-
function
|
|
349
|
-
var
|
|
350
|
-
const n = {},
|
|
351
|
-
|
|
352
|
-
const a =
|
|
348
|
+
function Ie(t, e = {}) {
|
|
349
|
+
var u;
|
|
350
|
+
const n = {}, c = Ne(t.number), r = Be(t.number);
|
|
351
|
+
r || (n.number = "Invalid card number");
|
|
352
|
+
const a = Le(t.expiry, e.now);
|
|
353
353
|
a || (n.expiry = "Invalid or expired");
|
|
354
|
-
const
|
|
355
|
-
|
|
356
|
-
const l = !e.requireHolder || (((
|
|
354
|
+
const i = (t.cvc || "").replace(/\D/g, "").length === ye(c);
|
|
355
|
+
i || (n.cvc = `CVC must be ${ye(c)} digits`);
|
|
356
|
+
const l = !e.requireHolder || (((u = t.holderName) == null ? void 0 : u.trim().length) ?? 0) >= 2;
|
|
357
357
|
return l || (n.holderName = "Cardholder name required"), {
|
|
358
|
-
brand:
|
|
359
|
-
numberValid:
|
|
358
|
+
brand: c,
|
|
359
|
+
numberValid: r,
|
|
360
360
|
expiryValid: a,
|
|
361
|
-
cvcValid:
|
|
361
|
+
cvcValid: i,
|
|
362
362
|
holderValid: l,
|
|
363
|
-
isValid:
|
|
363
|
+
isValid: r && a && i && l,
|
|
364
364
|
errors: n
|
|
365
365
|
};
|
|
366
366
|
}
|
|
367
|
-
class
|
|
367
|
+
class Lt {
|
|
368
368
|
constructor(e) {
|
|
369
|
-
|
|
369
|
+
K(this, "id", "static");
|
|
370
370
|
this.rates = e;
|
|
371
371
|
}
|
|
372
372
|
async getRate(e, n) {
|
|
373
|
-
const
|
|
374
|
-
if (
|
|
375
|
-
return { base:
|
|
376
|
-
const a = this.rates.find((
|
|
373
|
+
const c = e.toUpperCase(), r = n.toUpperCase();
|
|
374
|
+
if (c === r)
|
|
375
|
+
return { base: c, quote: r, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
376
|
+
const a = this.rates.find((u) => u.base === c && u.quote === r);
|
|
377
377
|
if (a)
|
|
378
378
|
return a;
|
|
379
|
-
const o = this.rates.find((
|
|
379
|
+
const o = this.rates.find((u) => u.base === r && u.quote === c);
|
|
380
380
|
if (o)
|
|
381
|
-
return { base:
|
|
382
|
-
const
|
|
383
|
-
if (
|
|
384
|
-
const
|
|
381
|
+
return { base: c, quote: r, rate: 1 / o.rate, asOf: o.asOf };
|
|
382
|
+
const i = this.rates.find((u) => u.base === c && u.quote === "USD") ?? this.rates.find((u) => u.base === "USD" && u.quote === c), l = this.rates.find((u) => u.base === "USD" && u.quote === r) ?? this.rates.find((u) => u.base === r && u.quote === "USD");
|
|
383
|
+
if (i && l) {
|
|
384
|
+
const u = i.base === "USD" ? 1 / i.rate : i.rate, m = l.base === "USD" ? l.rate : 1 / l.rate;
|
|
385
385
|
return {
|
|
386
|
-
base:
|
|
387
|
-
quote:
|
|
388
|
-
rate:
|
|
386
|
+
base: c,
|
|
387
|
+
quote: r,
|
|
388
|
+
rate: u * m,
|
|
389
389
|
asOf: (/* @__PURE__ */ new Date()).toISOString()
|
|
390
390
|
};
|
|
391
391
|
}
|
|
392
|
-
throw new Error(`No FX rate for ${
|
|
392
|
+
throw new Error(`No FX rate for ${c}/${r}`);
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
|
-
class
|
|
395
|
+
class ge {
|
|
396
396
|
constructor(e = {}) {
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
397
|
+
K(this, "cache", /* @__PURE__ */ new Map());
|
|
398
|
+
K(this, "fetchImpl");
|
|
399
|
+
K(this, "ttl");
|
|
400
400
|
this.fetchImpl = e.fetchImpl ?? fetch, this.ttl = e.cacheTtl ?? 6e4;
|
|
401
401
|
}
|
|
402
402
|
cacheKey(e, n) {
|
|
403
403
|
return `${this.id}:${e.toUpperCase()}/${n.toUpperCase()}`;
|
|
404
404
|
}
|
|
405
405
|
getCached(e, n) {
|
|
406
|
-
const
|
|
407
|
-
return
|
|
406
|
+
const c = this.cacheKey(e, n), r = this.cache.get(c);
|
|
407
|
+
return r && r.expires > Date.now() ? r.rate : (r && this.cache.delete(c), null);
|
|
408
408
|
}
|
|
409
409
|
setCached(e) {
|
|
410
410
|
this.cache.set(this.cacheKey(e.base, e.quote), {
|
|
@@ -413,93 +413,137 @@ class he {
|
|
|
413
413
|
});
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
|
-
class
|
|
416
|
+
class at extends ge {
|
|
417
417
|
constructor(n = {}) {
|
|
418
418
|
super(n);
|
|
419
|
-
|
|
419
|
+
K(this, "id", "frankfurter");
|
|
420
420
|
}
|
|
421
|
-
async getRate(n,
|
|
422
|
-
const
|
|
423
|
-
if (
|
|
424
|
-
return { base:
|
|
425
|
-
const o = this.getCached(
|
|
421
|
+
async getRate(n, c) {
|
|
422
|
+
const r = n.toUpperCase(), a = c.toUpperCase();
|
|
423
|
+
if (r === a)
|
|
424
|
+
return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
425
|
+
const o = this.getCached(r, a);
|
|
426
426
|
if (o)
|
|
427
427
|
return o;
|
|
428
|
-
const
|
|
428
|
+
const i = `https://api.frankfurter.app/latest?from=${r}&to=${a}`, l = await this.fetchImpl(i);
|
|
429
429
|
if (!l.ok)
|
|
430
430
|
throw new Error(`Frankfurter HTTP ${l.status}`);
|
|
431
|
-
const
|
|
432
|
-
if (
|
|
433
|
-
throw new Error(`Frankfurter: no rate for ${
|
|
434
|
-
const
|
|
435
|
-
return this.setCached(
|
|
431
|
+
const u = await l.json(), m = u.rates[a];
|
|
432
|
+
if (m == null)
|
|
433
|
+
throw new Error(`Frankfurter: no rate for ${r}/${a}`);
|
|
434
|
+
const b = { base: r, quote: a, rate: m, asOf: u.date };
|
|
435
|
+
return this.setCached(b), b;
|
|
436
436
|
}
|
|
437
437
|
}
|
|
438
|
-
class
|
|
439
|
-
constructor(n,
|
|
440
|
-
super(
|
|
441
|
-
|
|
438
|
+
class it extends ge {
|
|
439
|
+
constructor(n, c = {}) {
|
|
440
|
+
super(c);
|
|
441
|
+
K(this, "id", "openexchangerates");
|
|
442
442
|
this.appId = n;
|
|
443
443
|
}
|
|
444
|
-
async getRate(n,
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
return { base:
|
|
448
|
-
const o = this.getCached(
|
|
444
|
+
async getRate(n, c) {
|
|
445
|
+
const r = n.toUpperCase(), a = c.toUpperCase();
|
|
446
|
+
if (r === a)
|
|
447
|
+
return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
448
|
+
const o = this.getCached(r, a);
|
|
449
449
|
if (o)
|
|
450
450
|
return o;
|
|
451
|
-
const
|
|
451
|
+
const i = `https://openexchangerates.org/api/latest.json?app_id=${this.appId}`, l = await this.fetchImpl(i);
|
|
452
452
|
if (!l.ok)
|
|
453
453
|
throw new Error(`OpenExchangeRates HTTP ${l.status}`);
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
throw new Error(`OpenExchangeRates: missing rate for ${
|
|
457
|
-
const
|
|
458
|
-
base:
|
|
454
|
+
const u = await l.json(), m = u.rates[r], b = u.rates[a];
|
|
455
|
+
if (m == null || b == null)
|
|
456
|
+
throw new Error(`OpenExchangeRates: missing rate for ${r} or ${a}`);
|
|
457
|
+
const p = {
|
|
458
|
+
base: r,
|
|
459
459
|
quote: a,
|
|
460
|
-
rate:
|
|
461
|
-
asOf: new Date(
|
|
460
|
+
rate: b / m,
|
|
461
|
+
asOf: new Date(u.timestamp * 1e3).toISOString()
|
|
462
462
|
};
|
|
463
|
-
return this.setCached(
|
|
463
|
+
return this.setCached(p), p;
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
|
-
class
|
|
466
|
+
class st extends ge {
|
|
467
467
|
constructor(n = {}) {
|
|
468
468
|
super(n);
|
|
469
|
-
|
|
469
|
+
K(this, "id", "exchangerate.host");
|
|
470
470
|
}
|
|
471
|
-
async getRate(n,
|
|
472
|
-
var
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
475
|
-
return { base:
|
|
476
|
-
const o = this.getCached(
|
|
471
|
+
async getRate(n, c) {
|
|
472
|
+
var p;
|
|
473
|
+
const r = n.toUpperCase(), a = c.toUpperCase();
|
|
474
|
+
if (r === a)
|
|
475
|
+
return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
476
|
+
const o = this.getCached(r, a);
|
|
477
477
|
if (o)
|
|
478
478
|
return o;
|
|
479
|
-
const
|
|
479
|
+
const i = `https://api.exchangerate.host/convert?from=${r}&to=${a}`, l = await this.fetchImpl(i);
|
|
480
480
|
if (!l.ok)
|
|
481
481
|
throw new Error(`exchangerate.host HTTP ${l.status}`);
|
|
482
|
-
const
|
|
483
|
-
return this.setCached(
|
|
482
|
+
const u = await l.json(), m = ((p = u.info) == null ? void 0 : p.rate) ?? u.result, b = { base: r, quote: a, rate: m, asOf: u.date };
|
|
483
|
+
return this.setCached(b), b;
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
class ot extends ge {
|
|
487
|
+
constructor(n = {}) {
|
|
488
|
+
super(n);
|
|
489
|
+
K(this, "id", "nbp");
|
|
490
|
+
K(this, "table");
|
|
491
|
+
this.table = n.table ?? "A";
|
|
492
|
+
}
|
|
493
|
+
async getRate(n, c) {
|
|
494
|
+
const r = n.toUpperCase(), a = c.toUpperCase();
|
|
495
|
+
if (r === a) return { base: r, quote: a, rate: 1, asOf: (/* @__PURE__ */ new Date()).toISOString() };
|
|
496
|
+
const o = this.getCached(r, a);
|
|
497
|
+
if (o) return o;
|
|
498
|
+
const i = async (b) => {
|
|
499
|
+
var y;
|
|
500
|
+
if (b === "PLN") return { rate: 1, date: (/* @__PURE__ */ new Date()).toISOString().slice(0, 10) };
|
|
501
|
+
const p = `https://api.nbp.pl/api/exchangerates/rates/${this.table}/${b}/?format=json`, d = await this.fetchImpl(p);
|
|
502
|
+
if (!d.ok) return null;
|
|
503
|
+
const h = (y = (await d.json()).rates) == null ? void 0 : y[0];
|
|
504
|
+
return h ? { rate: h.mid ?? h.ask ?? 0, date: h.effectiveDate } : null;
|
|
505
|
+
}, l = await i(r), u = await i(a);
|
|
506
|
+
if (!l || !u || l.rate === 0)
|
|
507
|
+
throw new Error(`NBP: missing rate for ${r} or ${a}`);
|
|
508
|
+
const m = {
|
|
509
|
+
base: r,
|
|
510
|
+
quote: a,
|
|
511
|
+
rate: l.rate / u.rate,
|
|
512
|
+
asOf: l.date
|
|
513
|
+
};
|
|
514
|
+
return this.setCached(m), m;
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
class lt extends at {
|
|
518
|
+
constructor() {
|
|
519
|
+
super(...arguments);
|
|
520
|
+
K(this, "id", "ecb");
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
class ut extends st {
|
|
524
|
+
constructor() {
|
|
525
|
+
super(...arguments);
|
|
526
|
+
K(this, "id", "free-forex");
|
|
484
527
|
}
|
|
485
528
|
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
529
|
+
const qt = (t = {}) => new ot(t), Ht = (t = {}) => new lt(t), jt = (t) => new it(t.apiKey, t), zt = (t = {}) => new ut(t);
|
|
530
|
+
async function dt(t, e, n) {
|
|
531
|
+
const c = e.toUpperCase();
|
|
532
|
+
if (t.currency.toUpperCase() === c)
|
|
533
|
+
return t;
|
|
534
|
+
const r = V(t.currency), a = V(c), o = (r == null ? void 0 : r.decimals) ?? 2, i = (a == null ? void 0 : a.decimals) ?? 2, { rate: l } = await n.getRate(t.currency, c), m = t.amount / Math.pow(10, o) * l;
|
|
491
535
|
return {
|
|
492
|
-
currency:
|
|
493
|
-
amount: Math.round(
|
|
536
|
+
currency: c,
|
|
537
|
+
amount: Math.round(m * Math.pow(10, i))
|
|
494
538
|
};
|
|
495
539
|
}
|
|
496
|
-
class
|
|
540
|
+
class mt {
|
|
497
541
|
constructor(e = {}) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
542
|
+
K(this, "id");
|
|
543
|
+
K(this, "name");
|
|
544
|
+
K(this, "supportedCurrencies");
|
|
545
|
+
K(this, "minimums");
|
|
546
|
+
K(this, "counter", 0);
|
|
503
547
|
this.id = e.id ?? "mock", this.name = e.name ?? "Mock Processor", this.supportedCurrencies = e.supportedCurrencies ?? "*";
|
|
504
548
|
}
|
|
505
549
|
newId(e) {
|
|
@@ -534,28 +578,28 @@ class Ze {
|
|
|
534
578
|
};
|
|
535
579
|
}
|
|
536
580
|
}
|
|
537
|
-
function
|
|
581
|
+
function j(t, e, n, c, r) {
|
|
538
582
|
const a = (o) => {
|
|
539
|
-
const
|
|
540
|
-
return
|
|
583
|
+
const i = c == null ? void 0 : c[o];
|
|
584
|
+
return i || (async () => {
|
|
541
585
|
throw new Error(
|
|
542
586
|
`[ui-money] ${e} adapter is not wired. Pass an \`executor.${String(o)}\` implementation that calls the ${e} SDK.`
|
|
543
587
|
);
|
|
544
588
|
});
|
|
545
589
|
};
|
|
546
590
|
return {
|
|
547
|
-
id:
|
|
591
|
+
id: t,
|
|
548
592
|
name: e,
|
|
549
593
|
supportedCurrencies: n,
|
|
550
|
-
minimums:
|
|
594
|
+
minimums: r,
|
|
551
595
|
authorize: a("authorize"),
|
|
552
596
|
capture: a("capture"),
|
|
553
597
|
cancel: a("cancel"),
|
|
554
598
|
refund: a("refund")
|
|
555
599
|
};
|
|
556
600
|
}
|
|
557
|
-
function
|
|
558
|
-
return
|
|
601
|
+
function pt(t) {
|
|
602
|
+
return j("stripe", "Stripe", "*", t, {
|
|
559
603
|
USD: 50,
|
|
560
604
|
EUR: 50,
|
|
561
605
|
GBP: 30,
|
|
@@ -569,8 +613,8 @@ function Je(r) {
|
|
|
569
613
|
PLN: 200
|
|
570
614
|
});
|
|
571
615
|
}
|
|
572
|
-
function
|
|
573
|
-
return
|
|
616
|
+
function yt(t) {
|
|
617
|
+
return j(
|
|
574
618
|
"paypal",
|
|
575
619
|
"PayPal",
|
|
576
620
|
[
|
|
@@ -597,666 +641,705 @@ function Qe(r) {
|
|
|
597
641
|
"PHP",
|
|
598
642
|
"ILS"
|
|
599
643
|
],
|
|
600
|
-
|
|
644
|
+
t
|
|
601
645
|
);
|
|
602
646
|
}
|
|
603
|
-
function
|
|
604
|
-
return
|
|
647
|
+
function ft(t) {
|
|
648
|
+
return j("adyen", "Adyen", "*", t);
|
|
605
649
|
}
|
|
606
|
-
function
|
|
607
|
-
return
|
|
650
|
+
function ht(t) {
|
|
651
|
+
return j("square", "Square", ["USD", "CAD", "GBP", "AUD", "JPY", "EUR"], t);
|
|
608
652
|
}
|
|
609
|
-
function
|
|
610
|
-
return
|
|
653
|
+
function bt(t) {
|
|
654
|
+
return j("mollie", "Mollie", "*", t);
|
|
611
655
|
}
|
|
612
|
-
function
|
|
613
|
-
return
|
|
656
|
+
function _t(t) {
|
|
657
|
+
return j("braintree", "Braintree", "*", t);
|
|
614
658
|
}
|
|
615
|
-
function
|
|
616
|
-
return
|
|
659
|
+
function Nt(t) {
|
|
660
|
+
return j("razorpay", "Razorpay", ["INR", "USD", "EUR", "GBP", "AED"], t);
|
|
617
661
|
}
|
|
618
|
-
function
|
|
619
|
-
return
|
|
662
|
+
function gt(t) {
|
|
663
|
+
return j(
|
|
620
664
|
"payu",
|
|
621
665
|
"PayU",
|
|
622
666
|
["PLN", "EUR", "USD", "CZK", "HUF", "RON", "BGN", "TRY"],
|
|
623
|
-
|
|
667
|
+
t
|
|
624
668
|
);
|
|
625
669
|
}
|
|
626
|
-
function
|
|
627
|
-
return
|
|
670
|
+
function wt(t) {
|
|
671
|
+
return j("przelewy24", "Przelewy24", ["PLN", "EUR"], t);
|
|
672
|
+
}
|
|
673
|
+
function Dt(t = {}) {
|
|
674
|
+
return j("tpay", "Tpay", ["PLN", "EUR", "USD", "GBP"], t);
|
|
675
|
+
}
|
|
676
|
+
function vt(t = {}) {
|
|
677
|
+
return j("autopay", "Autopay", ["PLN", "EUR", "USD", "GBP", "CZK"], t);
|
|
678
|
+
}
|
|
679
|
+
function Ct(t = {}) {
|
|
680
|
+
const { acquirer: e = "native", ...n } = t;
|
|
681
|
+
return j(`blik:${e}`, `BLIK (${e})`, ["PLN"], n);
|
|
628
682
|
}
|
|
629
|
-
function
|
|
630
|
-
return
|
|
683
|
+
function $t(t) {
|
|
684
|
+
return j(
|
|
631
685
|
"klarna",
|
|
632
686
|
"Klarna",
|
|
633
687
|
["USD", "EUR", "GBP", "SEK", "NOK", "DKK", "CHF", "AUD", "CAD", "NZD", "PLN"],
|
|
634
|
-
|
|
688
|
+
t
|
|
635
689
|
);
|
|
636
690
|
}
|
|
637
|
-
function
|
|
638
|
-
return
|
|
691
|
+
function xt(t) {
|
|
692
|
+
return j(
|
|
639
693
|
"coinbase-commerce",
|
|
640
694
|
"Coinbase Commerce",
|
|
641
695
|
["BTC", "ETH", "USDC", "USDT", "USD", "EUR"],
|
|
642
|
-
|
|
696
|
+
t
|
|
643
697
|
);
|
|
644
698
|
}
|
|
645
|
-
const
|
|
646
|
-
mock: () => new
|
|
647
|
-
stripe: () =>
|
|
648
|
-
paypal: () =>
|
|
649
|
-
adyen: () =>
|
|
650
|
-
square: () =>
|
|
651
|
-
mollie: () =>
|
|
652
|
-
braintree: () =>
|
|
653
|
-
razorpay: () =>
|
|
654
|
-
payu: () =>
|
|
655
|
-
przelewy24: () =>
|
|
656
|
-
|
|
657
|
-
|
|
699
|
+
const Gt = {
|
|
700
|
+
mock: () => new mt(),
|
|
701
|
+
stripe: () => pt(),
|
|
702
|
+
paypal: () => yt(),
|
|
703
|
+
adyen: () => ft(),
|
|
704
|
+
square: () => ht(),
|
|
705
|
+
mollie: () => bt(),
|
|
706
|
+
braintree: () => _t(),
|
|
707
|
+
razorpay: () => Nt(),
|
|
708
|
+
payu: () => gt(),
|
|
709
|
+
przelewy24: () => wt(),
|
|
710
|
+
tpay: () => Dt(),
|
|
711
|
+
autopay: () => vt(),
|
|
712
|
+
blik: () => Ct(),
|
|
713
|
+
klarna: () => $t(),
|
|
714
|
+
"coinbase-commerce": () => xt()
|
|
658
715
|
};
|
|
659
|
-
function
|
|
660
|
-
const n =
|
|
661
|
-
() => "amount" in
|
|
662
|
-
|
|
663
|
-
|
|
716
|
+
function Yt(t, e) {
|
|
717
|
+
const n = k(
|
|
718
|
+
() => "amount" in t ? t : W(
|
|
719
|
+
t.major,
|
|
720
|
+
t.currency
|
|
664
721
|
),
|
|
665
722
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
666
723
|
[]
|
|
667
|
-
), [
|
|
668
|
-
(
|
|
724
|
+
), [c, r] = B(n), a = F(
|
|
725
|
+
(p) => r((d) => W(p, d.currency)),
|
|
669
726
|
[]
|
|
670
|
-
), o =
|
|
671
|
-
|
|
672
|
-
}, []),
|
|
673
|
-
(
|
|
727
|
+
), o = F((p) => {
|
|
728
|
+
r((d) => ({ ...d, currency: p.toUpperCase() }));
|
|
729
|
+
}, []), i = F((p) => r((d) => me(d, p)), []), l = F(
|
|
730
|
+
(p) => r((d) => nt(d, p)),
|
|
674
731
|
[]
|
|
675
|
-
),
|
|
676
|
-
(
|
|
732
|
+
), u = F(
|
|
733
|
+
(p) => r((d) => De(d, p)),
|
|
677
734
|
[]
|
|
678
|
-
),
|
|
679
|
-
return { money:
|
|
735
|
+
), m = k(() => te(c, { locale: e }), [c, e]), b = k(() => Ke(c), [c]);
|
|
736
|
+
return { money: c, setMoney: r, setMajor: a, setCurrency: o, add: i, subtract: l, scale: u, formatted: m, major: b };
|
|
680
737
|
}
|
|
681
|
-
function
|
|
682
|
-
const [
|
|
683
|
-
return
|
|
684
|
-
if (!
|
|
685
|
-
|
|
738
|
+
function ve(t, e, n) {
|
|
739
|
+
const [c, r] = B(null), [a, o] = B(null), [i, l] = B(!1), u = We(0);
|
|
740
|
+
return et(() => {
|
|
741
|
+
if (!t) {
|
|
742
|
+
r(null);
|
|
686
743
|
return;
|
|
687
744
|
}
|
|
688
|
-
const
|
|
689
|
-
l(!0), o(null),
|
|
690
|
-
|
|
691
|
-
}).catch((
|
|
692
|
-
|
|
745
|
+
const m = ++u.current;
|
|
746
|
+
l(!0), o(null), dt(t, e, n).then((b) => {
|
|
747
|
+
u.current === m && r(b);
|
|
748
|
+
}).catch((b) => {
|
|
749
|
+
u.current === m && (o(b instanceof Error ? b : new Error(String(b))), r(null));
|
|
693
750
|
}).finally(() => {
|
|
694
|
-
|
|
751
|
+
u.current === m && l(!1);
|
|
695
752
|
});
|
|
696
|
-
}, [
|
|
753
|
+
}, [t == null ? void 0 : t.amount, t == null ? void 0 : t.currency, e, n]), { converted: c, loading: i, error: a };
|
|
697
754
|
}
|
|
698
|
-
function
|
|
699
|
-
const [e, n] =
|
|
700
|
-
n("idle"),
|
|
701
|
-
}, []), l =
|
|
702
|
-
async (
|
|
755
|
+
function St(t) {
|
|
756
|
+
const [e, n] = B("idle"), [c, r] = B(null), [a, o] = B(null), i = F(() => {
|
|
757
|
+
n("idle"), r(null), o(null);
|
|
758
|
+
}, []), l = F(
|
|
759
|
+
async (p) => {
|
|
703
760
|
n("authorizing"), o(null);
|
|
704
761
|
try {
|
|
705
|
-
const d = await
|
|
706
|
-
return
|
|
762
|
+
const d = await t.authorize(p);
|
|
763
|
+
return r(d), n(d.status), d;
|
|
707
764
|
} catch (d) {
|
|
708
|
-
const
|
|
709
|
-
throw o(
|
|
765
|
+
const f = d instanceof Error ? d : new Error(String(d));
|
|
766
|
+
throw o(f), n("failed"), f;
|
|
710
767
|
}
|
|
711
768
|
},
|
|
712
|
-
[
|
|
713
|
-
),
|
|
714
|
-
async (
|
|
715
|
-
const
|
|
716
|
-
if (!
|
|
769
|
+
[t]
|
|
770
|
+
), u = F(
|
|
771
|
+
async (p, d) => {
|
|
772
|
+
const f = p ?? (c == null ? void 0 : c.id);
|
|
773
|
+
if (!f)
|
|
717
774
|
throw new Error("No authorization id to capture");
|
|
718
775
|
n("capturing");
|
|
719
776
|
try {
|
|
720
|
-
const
|
|
721
|
-
return
|
|
722
|
-
} catch (
|
|
723
|
-
const
|
|
724
|
-
throw o(
|
|
777
|
+
const h = await t.capture(f, d);
|
|
778
|
+
return r(h), n(h.status), h;
|
|
779
|
+
} catch (h) {
|
|
780
|
+
const y = h instanceof Error ? h : new Error(String(h));
|
|
781
|
+
throw o(y), n("failed"), y;
|
|
725
782
|
}
|
|
726
783
|
},
|
|
727
|
-
[
|
|
728
|
-
),
|
|
729
|
-
async (
|
|
730
|
-
const d =
|
|
784
|
+
[t, c == null ? void 0 : c.id]
|
|
785
|
+
), m = F(
|
|
786
|
+
async (p) => {
|
|
787
|
+
const d = p ?? (c == null ? void 0 : c.id);
|
|
731
788
|
if (!d)
|
|
732
789
|
throw new Error("No payment id to cancel");
|
|
733
|
-
const
|
|
734
|
-
return
|
|
790
|
+
const f = await t.cancel(d);
|
|
791
|
+
return r(f), n(f.status), f;
|
|
735
792
|
},
|
|
736
|
-
[
|
|
737
|
-
),
|
|
738
|
-
async (
|
|
739
|
-
const
|
|
740
|
-
if (!
|
|
793
|
+
[t, c == null ? void 0 : c.id]
|
|
794
|
+
), b = F(
|
|
795
|
+
async (p, d) => {
|
|
796
|
+
const f = p ?? (c == null ? void 0 : c.id);
|
|
797
|
+
if (!f)
|
|
741
798
|
throw new Error("No payment id to refund");
|
|
742
|
-
const
|
|
743
|
-
return
|
|
799
|
+
const h = await t.refund(f, d);
|
|
800
|
+
return r(h), n(h.status), h;
|
|
744
801
|
},
|
|
745
|
-
[
|
|
802
|
+
[t, c == null ? void 0 : c.id]
|
|
746
803
|
);
|
|
747
|
-
return { status: e, response:
|
|
804
|
+
return { status: e, response: c, error: a, authorize: l, capture: u, cancel: m, refund: b, reset: i };
|
|
748
805
|
}
|
|
749
|
-
const
|
|
806
|
+
const Fe = de(function({
|
|
750
807
|
value: e,
|
|
751
808
|
amount: n,
|
|
752
|
-
currency:
|
|
753
|
-
locale:
|
|
809
|
+
currency: c,
|
|
810
|
+
locale: r,
|
|
754
811
|
display: a = "symbol",
|
|
755
812
|
highlightNegative: o = !0,
|
|
756
|
-
zeroPlaceholder:
|
|
813
|
+
zeroPlaceholder: i,
|
|
757
814
|
convertTo: l,
|
|
758
|
-
exchangeProvider:
|
|
759
|
-
className:
|
|
760
|
-
style:
|
|
761
|
-
"aria-label":
|
|
815
|
+
exchangeProvider: u,
|
|
816
|
+
className: m,
|
|
817
|
+
style: b,
|
|
818
|
+
"aria-label": p
|
|
762
819
|
}, d) {
|
|
763
|
-
const
|
|
820
|
+
const f = k(() => {
|
|
764
821
|
if (e)
|
|
765
822
|
return e;
|
|
766
|
-
if (n != null &&
|
|
767
|
-
const
|
|
823
|
+
if (n != null && c) {
|
|
824
|
+
const g = V(c), v = (g == null ? void 0 : g.decimals) ?? 2;
|
|
768
825
|
return {
|
|
769
|
-
amount: Math.round(n * Math.pow(10,
|
|
770
|
-
currency:
|
|
826
|
+
amount: Math.round(n * Math.pow(10, v)),
|
|
827
|
+
currency: c.toUpperCase()
|
|
771
828
|
};
|
|
772
829
|
}
|
|
773
830
|
return null;
|
|
774
|
-
}, [e, n,
|
|
775
|
-
l &&
|
|
831
|
+
}, [e, n, c]), h = k(() => f ? f.amount === 0 && i != null ? i : te(f, { locale: r, currencyDisplay: a }) : "", [f, r, a, i]), { converted: y } = ve(
|
|
832
|
+
l && u ? f : null,
|
|
776
833
|
l ?? "",
|
|
777
|
-
|
|
834
|
+
u
|
|
778
835
|
);
|
|
779
|
-
if (!
|
|
836
|
+
if (!f)
|
|
780
837
|
return null;
|
|
781
|
-
const
|
|
782
|
-
return /* @__PURE__ */ N("span", { ref: d, className:
|
|
783
|
-
/* @__PURE__ */
|
|
784
|
-
|
|
838
|
+
const _ = f.amount < 0, S = "nice-money" + (o && _ ? " nice-money--negative" : "") + (m ? ` ${m}` : "");
|
|
839
|
+
return /* @__PURE__ */ N("span", { ref: d, className: S, style: b, "aria-label": p, children: [
|
|
840
|
+
/* @__PURE__ */ s("span", { className: "nice-money__value", children: h }),
|
|
841
|
+
y && /* @__PURE__ */ N("span", { className: "nice-money__converted", "aria-label": `Converted to ${y.currency}`, children: [
|
|
785
842
|
" ≈ ",
|
|
786
|
-
|
|
843
|
+
te(y, { locale: r })
|
|
787
844
|
] })
|
|
788
845
|
] });
|
|
789
|
-
}),
|
|
846
|
+
}), Zt = fe.map((t) => t.code).sort(), qe = de(
|
|
790
847
|
function({
|
|
791
848
|
value: e,
|
|
792
849
|
onChange: n,
|
|
793
|
-
options:
|
|
794
|
-
recents:
|
|
850
|
+
options: c = fe,
|
|
851
|
+
recents: r = [],
|
|
795
852
|
searchable: a,
|
|
796
853
|
showCode: o = !0,
|
|
797
|
-
showSymbol:
|
|
854
|
+
showSymbol: i = !0,
|
|
798
855
|
compact: l = !1,
|
|
799
|
-
disabled:
|
|
800
|
-
readOnly:
|
|
801
|
-
loading:
|
|
802
|
-
accessMode:
|
|
856
|
+
disabled: u,
|
|
857
|
+
readOnly: m,
|
|
858
|
+
loading: b,
|
|
859
|
+
accessMode: p,
|
|
803
860
|
label: d,
|
|
804
|
-
helperText:
|
|
805
|
-
error:
|
|
806
|
-
required:
|
|
807
|
-
size:
|
|
808
|
-
labelPlacement:
|
|
809
|
-
labelWidth:
|
|
810
|
-
controlWidth:
|
|
811
|
-
className:
|
|
812
|
-
style:
|
|
813
|
-
id:
|
|
814
|
-
name:
|
|
815
|
-
title:
|
|
816
|
-
"data-testid":
|
|
817
|
-
"aria-label":
|
|
818
|
-
placeholder:
|
|
819
|
-
},
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
return t.filter(
|
|
827
|
-
(S) => S.code.toLowerCase().includes(p) || S.name.toLowerCase().includes(p) || S.symbol.toLowerCase().includes(p)
|
|
861
|
+
helperText: f,
|
|
862
|
+
error: h,
|
|
863
|
+
required: y,
|
|
864
|
+
size: _ = "md",
|
|
865
|
+
labelPlacement: S = "top",
|
|
866
|
+
labelWidth: g,
|
|
867
|
+
controlWidth: v,
|
|
868
|
+
className: O,
|
|
869
|
+
style: Y,
|
|
870
|
+
id: Z,
|
|
871
|
+
name: R,
|
|
872
|
+
title: q,
|
|
873
|
+
"data-testid": ne,
|
|
874
|
+
"aria-label": E,
|
|
875
|
+
placeholder: J
|
|
876
|
+
}, z) {
|
|
877
|
+
const P = p === "hidden", X = u || p === "disabled" || b, se = m || p === "readOnly", A = Ce(), oe = Z ?? `nice-cs-${A}`, [H, U] = B(""), M = a ?? c.length > 8, T = k(() => {
|
|
878
|
+
if (!H.trim())
|
|
879
|
+
return c;
|
|
880
|
+
const D = H.trim().toLowerCase();
|
|
881
|
+
return c.filter(
|
|
882
|
+
(C) => C.code.toLowerCase().includes(D) || C.name.toLowerCase().includes(D) || C.symbol.toLowerCase().includes(D)
|
|
828
883
|
);
|
|
829
|
-
}, [
|
|
830
|
-
const
|
|
831
|
-
return
|
|
832
|
-
}, [
|
|
833
|
-
(
|
|
834
|
-
const
|
|
835
|
-
|
|
884
|
+
}, [c, H]), x = k(() => {
|
|
885
|
+
const D = /* @__PURE__ */ new Set();
|
|
886
|
+
return r.map((C) => V(C)).filter((C) => !!C && !D.has(C.code) && !!D.add(C.code));
|
|
887
|
+
}, [r]), le = F(
|
|
888
|
+
(D) => {
|
|
889
|
+
const C = D.target.value, ce = V(C);
|
|
890
|
+
ce && (n == null || n(C, ce));
|
|
836
891
|
},
|
|
837
892
|
[n]
|
|
838
|
-
),
|
|
893
|
+
), ee = (D) => {
|
|
839
894
|
if (l)
|
|
840
|
-
return `${
|
|
841
|
-
const
|
|
842
|
-
return
|
|
843
|
-
},
|
|
844
|
-
width: typeof
|
|
895
|
+
return `${i ? D.symbol + " " : ""}${D.code}`;
|
|
896
|
+
const C = [];
|
|
897
|
+
return i && C.push(D.symbol), o && C.push(D.code), C.push("—", D.name), C.join(" ");
|
|
898
|
+
}, w = `nice-currency-selector nice-currency-selector--${_} nice-currency-selector--label-${S}` + (l ? " nice-currency-selector--compact" : "") + (h ? " nice-currency-selector--error" : "") + (X ? " nice-currency-selector--disabled" : "") + (O ? ` ${O}` : ""), I = S === "left" && g != null ? { width: typeof g == "number" ? `${g}px` : g, flex: "none" } : void 0, re = v != null ? {
|
|
899
|
+
width: typeof v == "number" ? `${v}px` : v,
|
|
845
900
|
flex: "none"
|
|
846
901
|
} : void 0;
|
|
847
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
848
|
-
d && /* @__PURE__ */ N("label", { htmlFor:
|
|
902
|
+
return P ? null : /* @__PURE__ */ N("div", { ref: z, className: w, style: Y, title: q, "data-testid": ne, children: [
|
|
903
|
+
d && /* @__PURE__ */ N("label", { htmlFor: oe, className: "nice-currency-selector__label", style: I, children: [
|
|
849
904
|
d,
|
|
850
|
-
|
|
905
|
+
y && /* @__PURE__ */ s("span", { className: "nice-currency-selector__required", "aria-hidden": !0, children: "*" })
|
|
851
906
|
] }),
|
|
852
|
-
/* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style:
|
|
853
|
-
|
|
907
|
+
/* @__PURE__ */ N("div", { className: "nice-currency-selector__inner", style: re, children: [
|
|
908
|
+
M && /* @__PURE__ */ s(
|
|
854
909
|
"input",
|
|
855
910
|
{
|
|
856
911
|
type: "search",
|
|
857
912
|
className: "nice-currency-selector__search",
|
|
858
913
|
placeholder: "Search currency…",
|
|
859
|
-
value:
|
|
860
|
-
onChange: (
|
|
861
|
-
disabled:
|
|
914
|
+
value: H,
|
|
915
|
+
onChange: (D) => U(D.target.value),
|
|
916
|
+
disabled: X || se,
|
|
862
917
|
"aria-label": "Search currency"
|
|
863
918
|
}
|
|
864
919
|
),
|
|
865
920
|
/* @__PURE__ */ N(
|
|
866
921
|
"select",
|
|
867
922
|
{
|
|
868
|
-
id:
|
|
869
|
-
name:
|
|
923
|
+
id: oe,
|
|
924
|
+
name: R,
|
|
870
925
|
className: "nice-currency-selector__select",
|
|
871
926
|
value: e ?? "",
|
|
872
|
-
onChange:
|
|
873
|
-
disabled:
|
|
874
|
-
required:
|
|
875
|
-
"aria-invalid": !!
|
|
876
|
-
"aria-label":
|
|
927
|
+
onChange: le,
|
|
928
|
+
disabled: X || se,
|
|
929
|
+
required: y,
|
|
930
|
+
"aria-invalid": !!h,
|
|
931
|
+
"aria-label": E ?? (typeof d == "string" ? d : "Currency"),
|
|
877
932
|
children: [
|
|
878
|
-
!e && /* @__PURE__ */
|
|
879
|
-
|
|
880
|
-
/* @__PURE__ */
|
|
933
|
+
!e && /* @__PURE__ */ s("option", { value: "", children: J ?? "Select currency…" }),
|
|
934
|
+
x.length > 0 && /* @__PURE__ */ s("optgroup", { label: "Recent", children: x.map((D) => /* @__PURE__ */ s("option", { value: D.code, children: ee(D) }, `r-${D.code}`)) }),
|
|
935
|
+
/* @__PURE__ */ s("optgroup", { label: x.length > 0 ? "All" : "", children: T.map((D) => /* @__PURE__ */ s("option", { value: D.code, children: ee(D) }, D.code)) })
|
|
881
936
|
]
|
|
882
937
|
}
|
|
883
938
|
)
|
|
884
939
|
] }),
|
|
885
|
-
(
|
|
940
|
+
(h || f) && /* @__PURE__ */ s(
|
|
886
941
|
"span",
|
|
887
942
|
{
|
|
888
|
-
className:
|
|
889
|
-
children:
|
|
943
|
+
className: h ? "nice-currency-selector__error" : "nice-currency-selector__helper",
|
|
944
|
+
children: h ?? f
|
|
890
945
|
}
|
|
891
946
|
)
|
|
892
947
|
] });
|
|
893
948
|
}
|
|
894
|
-
),
|
|
949
|
+
), He = de(
|
|
895
950
|
function({
|
|
896
951
|
value: e,
|
|
897
952
|
onChange: n,
|
|
898
|
-
currency:
|
|
899
|
-
onCurrencyChange:
|
|
953
|
+
currency: c,
|
|
954
|
+
onCurrencyChange: r,
|
|
900
955
|
currencies: a,
|
|
901
956
|
hideCurrencySelector: o,
|
|
902
|
-
min:
|
|
957
|
+
min: i,
|
|
903
958
|
max: l,
|
|
904
|
-
step:
|
|
905
|
-
locale:
|
|
906
|
-
placeholder:
|
|
907
|
-
label:
|
|
959
|
+
step: u,
|
|
960
|
+
locale: m,
|
|
961
|
+
placeholder: b,
|
|
962
|
+
label: p,
|
|
908
963
|
helperText: d,
|
|
909
|
-
error:
|
|
910
|
-
size:
|
|
911
|
-
disabled:
|
|
912
|
-
readOnly:
|
|
913
|
-
required:
|
|
914
|
-
loading:
|
|
915
|
-
accessMode:
|
|
916
|
-
labelPlacement:
|
|
917
|
-
errorPlacement:
|
|
918
|
-
labelWidth:
|
|
919
|
-
controlWidth:
|
|
920
|
-
submitOnEnter:
|
|
921
|
-
onSubmit:
|
|
922
|
-
showFormattedPreview:
|
|
923
|
-
showSteppers:
|
|
924
|
-
className:
|
|
925
|
-
style:
|
|
926
|
-
id:
|
|
927
|
-
name:
|
|
928
|
-
title:
|
|
929
|
-
"data-testid":
|
|
930
|
-
onBlur:
|
|
931
|
-
onFocus:
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
const
|
|
937
|
-
() => e ? (e.amount / Math.pow(10,
|
|
938
|
-
), [
|
|
939
|
-
|
|
940
|
-
if (
|
|
964
|
+
error: f,
|
|
965
|
+
size: h = "md",
|
|
966
|
+
disabled: y,
|
|
967
|
+
readOnly: _,
|
|
968
|
+
required: S,
|
|
969
|
+
loading: g,
|
|
970
|
+
accessMode: v,
|
|
971
|
+
labelPlacement: O = "top",
|
|
972
|
+
errorPlacement: Y = "bottom",
|
|
973
|
+
labelWidth: Z,
|
|
974
|
+
controlWidth: R,
|
|
975
|
+
submitOnEnter: q,
|
|
976
|
+
onSubmit: ne,
|
|
977
|
+
showFormattedPreview: E = !0,
|
|
978
|
+
showSteppers: J = !1,
|
|
979
|
+
className: z,
|
|
980
|
+
style: P,
|
|
981
|
+
id: X,
|
|
982
|
+
name: se,
|
|
983
|
+
title: A,
|
|
984
|
+
"data-testid": oe,
|
|
985
|
+
onBlur: H,
|
|
986
|
+
onFocus: U,
|
|
987
|
+
liveGrouping: M,
|
|
988
|
+
multiplierShortcuts: T = !0,
|
|
989
|
+
onValidationError: x
|
|
990
|
+
}, le) {
|
|
991
|
+
const ee = y || v === "disabled" || g, w = _ || v === "readOnly", I = v === "hidden", re = Ce(), D = X ?? `nice-money-${re}`, C = ((e == null ? void 0 : e.currency) ?? c ?? "USD").toUpperCase(), ce = V(C), G = (ce == null ? void 0 : ce.decimals) ?? 2, xe = u ?? 1 / Math.pow(10, G), [we, he] = B(
|
|
992
|
+
() => e ? (e.amount / Math.pow(10, G)).toFixed(G) : ""
|
|
993
|
+
), [be, Se] = B(!1);
|
|
994
|
+
Ve.useEffect(() => {
|
|
995
|
+
if (be)
|
|
941
996
|
return;
|
|
942
997
|
if (e == null) {
|
|
943
|
-
|
|
998
|
+
he("");
|
|
944
999
|
return;
|
|
945
1000
|
}
|
|
946
|
-
const
|
|
947
|
-
|
|
948
|
-
}, [e,
|
|
949
|
-
const
|
|
950
|
-
(
|
|
951
|
-
|
|
952
|
-
if (
|
|
1001
|
+
const $ = V(e.currency), L = ($ == null ? void 0 : $.decimals) ?? 2;
|
|
1002
|
+
he((e.amount / Math.pow(10, L)).toFixed(L));
|
|
1003
|
+
}, [e, be]);
|
|
1004
|
+
const Ue = F(
|
|
1005
|
+
($) => {
|
|
1006
|
+
let L = $;
|
|
1007
|
+
if (T) {
|
|
1008
|
+
const ie = $.trim().match(/^([+-]?\d+(?:[.,]\d+)?)\s*([kKmMbB])$/);
|
|
1009
|
+
if (ie) {
|
|
1010
|
+
const ue = ie[2].toLowerCase() === "k" ? 1e3 : ie[2].toLowerCase() === "m" ? 1e6 : 1e9, ke = Number(ie[1].replace(",", ".")) * ue;
|
|
1011
|
+
if (!Number.isFinite(ke)) {
|
|
1012
|
+
x == null || x(new Error("overflow"));
|
|
1013
|
+
return;
|
|
1014
|
+
}
|
|
1015
|
+
L = String(ke);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1018
|
+
const Q = rt(L, C);
|
|
1019
|
+
if (!Q) {
|
|
953
1020
|
n == null || n(null);
|
|
954
1021
|
return;
|
|
955
1022
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1023
|
+
if (!Number.isSafeInteger(Q.amount)) {
|
|
1024
|
+
x == null || x(new Error("overflow: amount exceeds Number.MAX_SAFE_INTEGER"));
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
const ae = Q.amount / Math.pow(10, G);
|
|
1028
|
+
if (i != null && ae < i) {
|
|
1029
|
+
x == null || x(new Error(`min: ${i}`)), n == null || n(W(i, C));
|
|
959
1030
|
return;
|
|
960
1031
|
}
|
|
961
|
-
if (l != null &&
|
|
962
|
-
n == null || n(
|
|
1032
|
+
if (l != null && ae > l) {
|
|
1033
|
+
x == null || x(new Error(`max: ${l}`)), n == null || n(W(l, C));
|
|
963
1034
|
return;
|
|
964
1035
|
}
|
|
965
|
-
n == null || n(
|
|
1036
|
+
n == null || n(Q);
|
|
966
1037
|
},
|
|
967
|
-
[
|
|
968
|
-
),
|
|
969
|
-
(
|
|
970
|
-
const
|
|
971
|
-
|
|
1038
|
+
[C, G, i, l, n, T, x]
|
|
1039
|
+
), je = F(
|
|
1040
|
+
($) => {
|
|
1041
|
+
const L = $.target.value;
|
|
1042
|
+
he(L), Ue(L);
|
|
972
1043
|
},
|
|
973
|
-
[
|
|
974
|
-
),
|
|
975
|
-
(
|
|
976
|
-
const
|
|
977
|
-
n == null || n(
|
|
1044
|
+
[Ue]
|
|
1045
|
+
), Re = F(
|
|
1046
|
+
($) => {
|
|
1047
|
+
const Q = (e ? e.amount / Math.pow(10, G) : 0) + $, ae = Math.min(l ?? 1 / 0, Math.max(i ?? -1 / 0, Q));
|
|
1048
|
+
n == null || n(W(ae, C));
|
|
978
1049
|
},
|
|
979
|
-
[e,
|
|
980
|
-
),
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1050
|
+
[e, G, i, l, C, n]
|
|
1051
|
+
), _e = k(() => {
|
|
1052
|
+
var $, L;
|
|
1053
|
+
try {
|
|
1054
|
+
const Q = new Intl.NumberFormat(m).formatToParts(12345.6), ae = (($ = Q.find((ue) => ue.type === "group")) == null ? void 0 : $.value) ?? ",", ie = ((L = Q.find((ue) => ue.type === "decimal")) == null ? void 0 : L.value) ?? ".";
|
|
1055
|
+
return { group: ae, decimal: ie };
|
|
1056
|
+
} catch {
|
|
1057
|
+
return { group: ",", decimal: "." };
|
|
1058
|
+
}
|
|
1059
|
+
}, [m]), Me = M ?? !!_e.group, ze = k(() => {
|
|
1060
|
+
if (!Me || be === !1) return we;
|
|
1061
|
+
const $ = _e.decimal, L = _e.group, Q = we.replace(new RegExp(`[${L.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}]`, "g"), ""), [ae, ie] = Q.split($);
|
|
1062
|
+
if (!ae) return Q;
|
|
1063
|
+
const ue = ae.replace(/\B(?=(\d{3})+(?!\d))/g, L);
|
|
1064
|
+
return ie != null ? `${ue}${$}${ie}` : ue;
|
|
1065
|
+
}, [we, be, Me, _e]), Pe = k(() => e ? te(e, { locale: m }) : "", [e, m]), pe = typeof f == "string" ? f : void 0, Ge = `nice-money-input nice-money-input--${h} nice-money-input--label-${O} nice-money-input--error-${Y}` + (pe ? " nice-money-input--error" : "") + (ee ? " nice-money-input--disabled" : "") + (g ? " nice-money-input--loading" : "") + (z ? ` ${z}` : ""), Ye = ($) => {
|
|
1066
|
+
q && $.key === "Enter" && ne && ($.preventDefault(), ne());
|
|
1067
|
+
}, Ze = O === "left" && Z != null ? { width: typeof Z == "number" ? `${Z}px` : Z, flex: "none" } : void 0, Je = R != null ? {
|
|
1068
|
+
width: typeof R == "number" ? `${R}px` : R,
|
|
984
1069
|
flex: "none"
|
|
985
1070
|
} : void 0;
|
|
986
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
1071
|
+
return I ? null : /* @__PURE__ */ N("div", { ref: le, className: Ge, style: P, title: A, "data-testid": oe, children: [
|
|
1072
|
+
p && /* @__PURE__ */ N("label", { htmlFor: D, className: "nice-money-input__label", style: Ze, children: [
|
|
1073
|
+
p,
|
|
1074
|
+
S && /* @__PURE__ */ s("span", { className: "nice-money-input__required", "aria-hidden": !0, children: "*" })
|
|
990
1075
|
] }),
|
|
991
|
-
/* @__PURE__ */ N("div", { className: "nice-money-input__row", style:
|
|
992
|
-
!o && /* @__PURE__ */
|
|
993
|
-
|
|
1076
|
+
/* @__PURE__ */ N("div", { className: "nice-money-input__row", style: Je, children: [
|
|
1077
|
+
!o && /* @__PURE__ */ s(
|
|
1078
|
+
qe,
|
|
994
1079
|
{
|
|
995
|
-
value:
|
|
1080
|
+
value: C,
|
|
996
1081
|
compact: !0,
|
|
997
|
-
options: a ? a.map(
|
|
998
|
-
onChange: (
|
|
999
|
-
disabled:
|
|
1082
|
+
options: a ? a.map(V).filter(($) => !!$) : void 0,
|
|
1083
|
+
onChange: ($) => r == null ? void 0 : r($),
|
|
1084
|
+
disabled: ee || w,
|
|
1000
1085
|
className: "nice-money-input__currency",
|
|
1001
1086
|
"aria-label": "Currency"
|
|
1002
1087
|
}
|
|
1003
1088
|
),
|
|
1004
|
-
o && /* @__PURE__ */
|
|
1005
|
-
|
|
1089
|
+
o && /* @__PURE__ */ s("span", { className: "nice-money-input__symbol", "aria-hidden": !0, children: (ce == null ? void 0 : ce.symbol) ?? C }),
|
|
1090
|
+
J && /* @__PURE__ */ s(
|
|
1006
1091
|
"button",
|
|
1007
1092
|
{
|
|
1008
1093
|
type: "button",
|
|
1009
1094
|
className: "nice-money-input__step nice-money-input__step--down",
|
|
1010
|
-
onClick: () =>
|
|
1011
|
-
disabled:
|
|
1095
|
+
onClick: () => Re(-xe),
|
|
1096
|
+
disabled: ee || w || i != null && e != null && e.amount / Math.pow(10, G) <= i,
|
|
1012
1097
|
"aria-label": "Decrease amount",
|
|
1013
1098
|
tabIndex: -1,
|
|
1014
1099
|
children: "−"
|
|
1015
1100
|
}
|
|
1016
1101
|
),
|
|
1017
|
-
/* @__PURE__ */
|
|
1102
|
+
/* @__PURE__ */ s(
|
|
1018
1103
|
"input",
|
|
1019
1104
|
{
|
|
1020
|
-
id:
|
|
1021
|
-
name:
|
|
1105
|
+
id: D,
|
|
1106
|
+
name: se,
|
|
1022
1107
|
type: "text",
|
|
1023
1108
|
inputMode: "decimal",
|
|
1024
1109
|
autoComplete: "transaction-amount",
|
|
1025
1110
|
className: "nice-money-input__amount",
|
|
1026
|
-
value:
|
|
1027
|
-
onChange:
|
|
1028
|
-
onKeyDown:
|
|
1029
|
-
onFocus: (
|
|
1030
|
-
|
|
1111
|
+
value: ze,
|
|
1112
|
+
onChange: je,
|
|
1113
|
+
onKeyDown: Ye,
|
|
1114
|
+
onFocus: ($) => {
|
|
1115
|
+
Se(!0), U == null || U($);
|
|
1031
1116
|
},
|
|
1032
|
-
onBlur: (
|
|
1033
|
-
|
|
1117
|
+
onBlur: ($) => {
|
|
1118
|
+
Se(!1), e && he((e.amount / Math.pow(10, G)).toFixed(G)), H == null || H($);
|
|
1034
1119
|
},
|
|
1035
|
-
placeholder:
|
|
1036
|
-
disabled:
|
|
1037
|
-
readOnly:
|
|
1038
|
-
required:
|
|
1039
|
-
"aria-invalid": !!
|
|
1040
|
-
"aria-describedby":
|
|
1120
|
+
placeholder: b ?? `0${G > 0 ? "." + "0".repeat(G) : ""}`,
|
|
1121
|
+
disabled: ee,
|
|
1122
|
+
readOnly: w,
|
|
1123
|
+
required: S,
|
|
1124
|
+
"aria-invalid": !!pe,
|
|
1125
|
+
"aria-describedby": pe || d ? `${D}-help` : void 0
|
|
1041
1126
|
}
|
|
1042
1127
|
),
|
|
1043
|
-
|
|
1128
|
+
J && /* @__PURE__ */ s(
|
|
1044
1129
|
"button",
|
|
1045
1130
|
{
|
|
1046
1131
|
type: "button",
|
|
1047
1132
|
className: "nice-money-input__step nice-money-input__step--up",
|
|
1048
|
-
onClick: () =>
|
|
1049
|
-
disabled:
|
|
1133
|
+
onClick: () => Re(xe),
|
|
1134
|
+
disabled: ee || w || l != null && e != null && e.amount / Math.pow(10, G) >= l,
|
|
1050
1135
|
"aria-label": "Increase amount",
|
|
1051
1136
|
tabIndex: -1,
|
|
1052
1137
|
children: "+"
|
|
1053
1138
|
}
|
|
1054
1139
|
),
|
|
1055
|
-
|
|
1140
|
+
g && /* @__PURE__ */ s("span", { className: "nice-money-input__spinner", "aria-hidden": !0, children: "⟳" })
|
|
1056
1141
|
] }),
|
|
1057
|
-
|
|
1058
|
-
(
|
|
1142
|
+
E && Pe && /* @__PURE__ */ s("span", { className: "nice-money-input__preview", "aria-live": "polite", children: Pe }),
|
|
1143
|
+
(pe || d) && /* @__PURE__ */ s(
|
|
1059
1144
|
"span",
|
|
1060
1145
|
{
|
|
1061
|
-
id: `${
|
|
1062
|
-
className:
|
|
1063
|
-
children:
|
|
1146
|
+
id: `${D}-help`,
|
|
1147
|
+
className: pe ? "nice-money-input__error" : "nice-money-input__helper",
|
|
1148
|
+
children: pe ?? d
|
|
1064
1149
|
}
|
|
1065
1150
|
)
|
|
1066
1151
|
] });
|
|
1067
1152
|
}
|
|
1068
|
-
),
|
|
1153
|
+
), Ut = { number: "", expiry: "", cvc: "" }, Rt = de(
|
|
1069
1154
|
function({
|
|
1070
|
-
value: e =
|
|
1155
|
+
value: e = Ut,
|
|
1071
1156
|
onChange: n,
|
|
1072
|
-
showHolderName:
|
|
1073
|
-
requireHolderName:
|
|
1157
|
+
showHolderName: c = !0,
|
|
1158
|
+
requireHolderName: r,
|
|
1074
1159
|
showPostalCode: a = !1,
|
|
1075
1160
|
acceptedBrands: o,
|
|
1076
|
-
showBrandIcon:
|
|
1161
|
+
showBrandIcon: i = !0,
|
|
1077
1162
|
size: l = "md",
|
|
1078
|
-
disabled:
|
|
1079
|
-
readOnly:
|
|
1080
|
-
loading:
|
|
1081
|
-
accessMode:
|
|
1163
|
+
disabled: u,
|
|
1164
|
+
readOnly: m,
|
|
1165
|
+
loading: b,
|
|
1166
|
+
accessMode: p,
|
|
1082
1167
|
label: d,
|
|
1083
|
-
helperText:
|
|
1084
|
-
error:
|
|
1085
|
-
required:
|
|
1086
|
-
className:
|
|
1087
|
-
style:
|
|
1088
|
-
id:
|
|
1089
|
-
title:
|
|
1090
|
-
"data-testid":
|
|
1091
|
-
},
|
|
1092
|
-
|
|
1093
|
-
return null;
|
|
1094
|
-
const A = s || m === "disabled" || h, M = y || m === "readOnly", ne = ye(), x = I ?? `nice-cc-${ne}`, [V, O] = E({
|
|
1168
|
+
helperText: f,
|
|
1169
|
+
error: h,
|
|
1170
|
+
required: y,
|
|
1171
|
+
className: _,
|
|
1172
|
+
style: S,
|
|
1173
|
+
id: g,
|
|
1174
|
+
title: v,
|
|
1175
|
+
"data-testid": O
|
|
1176
|
+
}, Y) {
|
|
1177
|
+
const Z = p === "hidden", R = u || p === "disabled" || b, q = m || p === "readOnly", ne = Ce(), E = g ?? `nice-cc-${ne}`, [J, z] = B({
|
|
1095
1178
|
number: !1,
|
|
1096
1179
|
expiry: !1,
|
|
1097
1180
|
cvc: !1,
|
|
1098
1181
|
holder: !1,
|
|
1099
1182
|
postal: !1
|
|
1100
|
-
}),
|
|
1101
|
-
() =>
|
|
1102
|
-
[e,
|
|
1103
|
-
),
|
|
1104
|
-
(
|
|
1105
|
-
const
|
|
1106
|
-
n == null || n(
|
|
1183
|
+
}), P = k(() => Ne(e.number), [e.number]), X = k(
|
|
1184
|
+
() => Ie(e, { requireHolder: r ?? c }),
|
|
1185
|
+
[e, r, c]
|
|
1186
|
+
), se = !o || o.includes(P) || P === "unknown", A = F(
|
|
1187
|
+
(w) => {
|
|
1188
|
+
const I = { ...e, ...w }, re = Ie(I, { requireHolder: r ?? c });
|
|
1189
|
+
n == null || n(I, re);
|
|
1107
1190
|
},
|
|
1108
|
-
[e,
|
|
1109
|
-
),
|
|
1110
|
-
(
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1191
|
+
[e, r, c, n]
|
|
1192
|
+
), oe = F(
|
|
1193
|
+
(w) => {
|
|
1194
|
+
const I = w.target.value.replace(/\D/g, "").slice(0, 19);
|
|
1195
|
+
A({ number: I });
|
|
1113
1196
|
},
|
|
1114
|
-
[
|
|
1115
|
-
),
|
|
1116
|
-
(
|
|
1117
|
-
const
|
|
1118
|
-
let
|
|
1119
|
-
|
|
1197
|
+
[A]
|
|
1198
|
+
), H = F(
|
|
1199
|
+
(w) => {
|
|
1200
|
+
const I = w.target.value.replace(/\D/g, "").slice(0, 4);
|
|
1201
|
+
let re = I;
|
|
1202
|
+
I.length >= 3 ? re = `${I.slice(0, 2)}/${I.slice(2)}` : I.length === 2 && (re = `${I}/`), A({ expiry: re });
|
|
1120
1203
|
},
|
|
1121
|
-
[
|
|
1122
|
-
),
|
|
1123
|
-
(
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1204
|
+
[A]
|
|
1205
|
+
), U = F(
|
|
1206
|
+
(w) => {
|
|
1207
|
+
const I = w.target.value.replace(/\D/g, "").slice(0, ye(P));
|
|
1208
|
+
A({ cvc: I });
|
|
1126
1209
|
},
|
|
1127
|
-
[
|
|
1128
|
-
),
|
|
1129
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
1210
|
+
[P, A]
|
|
1211
|
+
), M = k(() => ct(e.number, P), [e.number, P]), T = J.number && e.number.length > 0 && (Be(e.number) ? se ? void 0 : "Card brand not accepted" : X.errors.number), x = J.expiry && e.expiry.length > 0 && !Le(e.expiry) ? X.errors.expiry : void 0, le = J.cvc && e.cvc.length > 0 && e.cvc.length !== ye(P) ? X.errors.cvc : void 0, ee = `nice-credit-card nice-credit-card--${l}` + (R ? " nice-credit-card--disabled" : "") + (b ? " nice-credit-card--loading" : "") + (h ? " nice-credit-card--error" : "") + (_ ? ` ${_}` : "");
|
|
1212
|
+
return Z ? null : /* @__PURE__ */ N("div", { ref: Y, className: ee, style: S, title: v, "data-testid": O, children: [
|
|
1130
1213
|
d && /* @__PURE__ */ N("div", { className: "nice-credit-card__title", children: [
|
|
1131
1214
|
d,
|
|
1132
|
-
|
|
1215
|
+
y && /* @__PURE__ */ s("span", { className: "nice-credit-card__required", "aria-hidden": !0, children: "*" })
|
|
1133
1216
|
] }),
|
|
1134
|
-
/* @__PURE__ */
|
|
1135
|
-
/* @__PURE__ */
|
|
1217
|
+
/* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field nice-credit-card__field--number", children: [
|
|
1218
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Card number" }),
|
|
1136
1219
|
/* @__PURE__ */ N("span", { className: "nice-credit-card__input-wrapper", children: [
|
|
1137
|
-
/* @__PURE__ */
|
|
1220
|
+
/* @__PURE__ */ s(
|
|
1138
1221
|
"input",
|
|
1139
1222
|
{
|
|
1140
|
-
id: `${
|
|
1223
|
+
id: `${E}-number`,
|
|
1141
1224
|
type: "text",
|
|
1142
1225
|
inputMode: "numeric",
|
|
1143
1226
|
autoComplete: "cc-number",
|
|
1144
|
-
placeholder:
|
|
1145
|
-
value:
|
|
1146
|
-
onChange:
|
|
1147
|
-
onBlur: () =>
|
|
1148
|
-
disabled:
|
|
1149
|
-
readOnly:
|
|
1150
|
-
"aria-invalid": !!
|
|
1151
|
-
"aria-describedby":
|
|
1227
|
+
placeholder: P === "amex" ? "3782 822463 10005" : "1234 1234 1234 1234",
|
|
1228
|
+
value: M,
|
|
1229
|
+
onChange: oe,
|
|
1230
|
+
onBlur: () => z((w) => ({ ...w, number: !0 })),
|
|
1231
|
+
disabled: R,
|
|
1232
|
+
readOnly: q,
|
|
1233
|
+
"aria-invalid": !!T,
|
|
1234
|
+
"aria-describedby": T ? `${E}-number-err` : void 0,
|
|
1152
1235
|
className: "nice-credit-card__input",
|
|
1153
|
-
maxLength:
|
|
1236
|
+
maxLength: P === "amex" ? 17 : 23
|
|
1154
1237
|
}
|
|
1155
1238
|
),
|
|
1156
|
-
|
|
1239
|
+
i && /* @__PURE__ */ s(Mt, { brand: P })
|
|
1157
1240
|
] }),
|
|
1158
|
-
|
|
1241
|
+
T && /* @__PURE__ */ s("span", { id: `${E}-number-err`, className: "nice-credit-card__error", children: T })
|
|
1159
1242
|
] }) }),
|
|
1160
1243
|
/* @__PURE__ */ N("div", { className: "nice-credit-card__row nice-credit-card__row--split", children: [
|
|
1161
1244
|
/* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1162
|
-
/* @__PURE__ */
|
|
1163
|
-
/* @__PURE__ */
|
|
1245
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Expiry" }),
|
|
1246
|
+
/* @__PURE__ */ s(
|
|
1164
1247
|
"input",
|
|
1165
1248
|
{
|
|
1166
|
-
id: `${
|
|
1249
|
+
id: `${E}-expiry`,
|
|
1167
1250
|
type: "text",
|
|
1168
1251
|
inputMode: "numeric",
|
|
1169
1252
|
autoComplete: "cc-exp",
|
|
1170
1253
|
placeholder: "MM/YY",
|
|
1171
1254
|
value: e.expiry,
|
|
1172
|
-
onChange:
|
|
1255
|
+
onChange: H,
|
|
1173
1256
|
onBlur: () => {
|
|
1174
|
-
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1257
|
+
z((I) => ({ ...I, expiry: !0 }));
|
|
1258
|
+
const w = Te(e.expiry);
|
|
1259
|
+
w && w !== e.expiry && A({ expiry: w });
|
|
1177
1260
|
},
|
|
1178
|
-
disabled:
|
|
1179
|
-
readOnly:
|
|
1180
|
-
"aria-invalid":
|
|
1181
|
-
"aria-describedby":
|
|
1261
|
+
disabled: R,
|
|
1262
|
+
readOnly: q,
|
|
1263
|
+
"aria-invalid": !!x,
|
|
1264
|
+
"aria-describedby": x ? `${E}-expiry-err` : void 0,
|
|
1182
1265
|
className: "nice-credit-card__input",
|
|
1183
1266
|
maxLength: 5
|
|
1184
1267
|
}
|
|
1185
1268
|
),
|
|
1186
|
-
|
|
1269
|
+
x && /* @__PURE__ */ s("span", { id: `${E}-expiry-err`, className: "nice-credit-card__error", children: x })
|
|
1187
1270
|
] }),
|
|
1188
1271
|
/* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1189
|
-
/* @__PURE__ */
|
|
1190
|
-
/* @__PURE__ */
|
|
1272
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: P === "amex" ? "CID" : "CVC" }),
|
|
1273
|
+
/* @__PURE__ */ s(
|
|
1191
1274
|
"input",
|
|
1192
1275
|
{
|
|
1193
|
-
id: `${
|
|
1276
|
+
id: `${E}-cvc`,
|
|
1194
1277
|
type: "text",
|
|
1195
1278
|
inputMode: "numeric",
|
|
1196
1279
|
autoComplete: "cc-csc",
|
|
1197
|
-
placeholder: "•".repeat(
|
|
1280
|
+
placeholder: "•".repeat(ye(P)),
|
|
1198
1281
|
value: e.cvc,
|
|
1199
|
-
onChange:
|
|
1200
|
-
onBlur: () =>
|
|
1201
|
-
disabled:
|
|
1202
|
-
readOnly:
|
|
1203
|
-
"aria-invalid": !!
|
|
1204
|
-
"aria-describedby":
|
|
1282
|
+
onChange: U,
|
|
1283
|
+
onBlur: () => z((w) => ({ ...w, cvc: !0 })),
|
|
1284
|
+
disabled: R,
|
|
1285
|
+
readOnly: q,
|
|
1286
|
+
"aria-invalid": !!le,
|
|
1287
|
+
"aria-describedby": le ? `${E}-cvc-err` : void 0,
|
|
1205
1288
|
className: "nice-credit-card__input",
|
|
1206
|
-
maxLength:
|
|
1289
|
+
maxLength: ye(P)
|
|
1207
1290
|
}
|
|
1208
1291
|
),
|
|
1209
|
-
|
|
1292
|
+
le && /* @__PURE__ */ s("span", { id: `${E}-cvc-err`, className: "nice-credit-card__error", children: le })
|
|
1210
1293
|
] })
|
|
1211
1294
|
] }),
|
|
1212
|
-
|
|
1213
|
-
/* @__PURE__ */
|
|
1214
|
-
/* @__PURE__ */
|
|
1295
|
+
c && /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1296
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Cardholder name" }),
|
|
1297
|
+
/* @__PURE__ */ s(
|
|
1215
1298
|
"input",
|
|
1216
1299
|
{
|
|
1217
|
-
id: `${
|
|
1300
|
+
id: `${E}-holder`,
|
|
1218
1301
|
type: "text",
|
|
1219
1302
|
autoComplete: "cc-name",
|
|
1220
1303
|
placeholder: "Jane Doe",
|
|
1221
1304
|
value: e.holderName ?? "",
|
|
1222
|
-
onChange: (
|
|
1223
|
-
onBlur: () =>
|
|
1224
|
-
disabled:
|
|
1225
|
-
readOnly:
|
|
1305
|
+
onChange: (w) => A({ holderName: w.target.value }),
|
|
1306
|
+
onBlur: () => z((w) => ({ ...w, holder: !0 })),
|
|
1307
|
+
disabled: R,
|
|
1308
|
+
readOnly: q,
|
|
1226
1309
|
className: "nice-credit-card__input",
|
|
1227
1310
|
maxLength: 120
|
|
1228
1311
|
}
|
|
1229
1312
|
)
|
|
1230
1313
|
] }) }),
|
|
1231
|
-
a && /* @__PURE__ */
|
|
1232
|
-
/* @__PURE__ */
|
|
1233
|
-
/* @__PURE__ */
|
|
1314
|
+
a && /* @__PURE__ */ s("div", { className: "nice-credit-card__row", children: /* @__PURE__ */ N("label", { className: "nice-credit-card__field", children: [
|
|
1315
|
+
/* @__PURE__ */ s("span", { className: "nice-credit-card__label", children: "Postal code" }),
|
|
1316
|
+
/* @__PURE__ */ s(
|
|
1234
1317
|
"input",
|
|
1235
1318
|
{
|
|
1236
|
-
id: `${
|
|
1319
|
+
id: `${E}-postal`,
|
|
1237
1320
|
type: "text",
|
|
1238
1321
|
autoComplete: "postal-code",
|
|
1239
1322
|
value: e.postalCode ?? "",
|
|
1240
|
-
onChange: (
|
|
1241
|
-
onBlur: () =>
|
|
1242
|
-
disabled:
|
|
1243
|
-
readOnly:
|
|
1323
|
+
onChange: (w) => A({ postalCode: w.target.value }),
|
|
1324
|
+
onBlur: () => z((w) => ({ ...w, postal: !0 })),
|
|
1325
|
+
disabled: R,
|
|
1326
|
+
readOnly: q,
|
|
1244
1327
|
className: "nice-credit-card__input",
|
|
1245
1328
|
maxLength: 16
|
|
1246
1329
|
}
|
|
1247
1330
|
)
|
|
1248
1331
|
] }) }),
|
|
1249
|
-
(
|
|
1332
|
+
(h || f) && /* @__PURE__ */ s(
|
|
1250
1333
|
"div",
|
|
1251
1334
|
{
|
|
1252
|
-
className:
|
|
1253
|
-
role:
|
|
1254
|
-
children:
|
|
1335
|
+
className: h ? "nice-credit-card__form-error" : "nice-credit-card__helper",
|
|
1336
|
+
role: h ? "alert" : void 0,
|
|
1337
|
+
children: h ?? f
|
|
1255
1338
|
}
|
|
1256
1339
|
)
|
|
1257
1340
|
] });
|
|
1258
1341
|
}
|
|
1259
|
-
),
|
|
1342
|
+
), Ee = {
|
|
1260
1343
|
visa: "VISA",
|
|
1261
1344
|
mastercard: "MasterCard",
|
|
1262
1345
|
amex: "AMEX",
|
|
@@ -1270,305 +1353,406 @@ const De = te(function({
|
|
|
1270
1353
|
hipercard: "Hipercard",
|
|
1271
1354
|
unknown: ""
|
|
1272
1355
|
};
|
|
1273
|
-
function
|
|
1274
|
-
return
|
|
1356
|
+
function Mt({ brand: t }) {
|
|
1357
|
+
return t === "unknown" ? null : /* @__PURE__ */ s(
|
|
1275
1358
|
"span",
|
|
1276
1359
|
{
|
|
1277
|
-
className: `nice-credit-card__brand nice-credit-card__brand--${
|
|
1278
|
-
"aria-label":
|
|
1279
|
-
children:
|
|
1360
|
+
className: `nice-credit-card__brand nice-credit-card__brand--${t}`,
|
|
1361
|
+
"aria-label": Ee[t],
|
|
1362
|
+
children: Ee[t]
|
|
1280
1363
|
}
|
|
1281
1364
|
);
|
|
1282
1365
|
}
|
|
1283
|
-
const
|
|
1366
|
+
const Jt = de(
|
|
1284
1367
|
function({
|
|
1285
1368
|
processor: e,
|
|
1286
1369
|
amount: n,
|
|
1287
|
-
editableAmount:
|
|
1288
|
-
customer:
|
|
1370
|
+
editableAmount: c,
|
|
1371
|
+
customer: r,
|
|
1289
1372
|
currencies: a,
|
|
1290
1373
|
description: o,
|
|
1291
|
-
metadata:
|
|
1374
|
+
metadata: i,
|
|
1292
1375
|
autoCapture: l = !0,
|
|
1293
|
-
submitLabel:
|
|
1294
|
-
onSuccess:
|
|
1295
|
-
onError:
|
|
1296
|
-
consents:
|
|
1376
|
+
submitLabel: u = "Pay",
|
|
1377
|
+
onSuccess: m,
|
|
1378
|
+
onError: b,
|
|
1379
|
+
consents: p,
|
|
1297
1380
|
className: d,
|
|
1298
|
-
style:
|
|
1299
|
-
},
|
|
1300
|
-
const [
|
|
1301
|
-
var
|
|
1302
|
-
const
|
|
1303
|
-
return
|
|
1304
|
-
}, [e,
|
|
1305
|
-
var
|
|
1306
|
-
const
|
|
1307
|
-
return
|
|
1308
|
-
}, [e,
|
|
1309
|
-
async (
|
|
1310
|
-
if (
|
|
1311
|
-
|
|
1381
|
+
style: f
|
|
1382
|
+
}, h) {
|
|
1383
|
+
const [y, _] = B(n), [S, g] = B(n.currency), [v, O] = B({ number: "", expiry: "", cvc: "" }), [Y, Z] = B(null), [R, q] = B(!1), [ne, E] = B(null), J = St(e), z = k(() => e.supportedCurrencies === "*" ? !0 : e.supportedCurrencies.includes(y.currency.toUpperCase()), [e, y.currency]), P = k(() => {
|
|
1384
|
+
var M;
|
|
1385
|
+
const U = (M = e.minimums) == null ? void 0 : M[y.currency.toUpperCase()];
|
|
1386
|
+
return U == null || y.amount >= U;
|
|
1387
|
+
}, [e, y]), X = k(() => {
|
|
1388
|
+
var M;
|
|
1389
|
+
const U = (M = e.minimums) == null ? void 0 : M[y.currency.toUpperCase()];
|
|
1390
|
+
return U == null ? null : { amount: U, currency: y.currency };
|
|
1391
|
+
}, [e, y.currency]), se = !!(Y != null && Y.isValid), A = !R && z && P && se, oe = F(
|
|
1392
|
+
async (U) => {
|
|
1393
|
+
if (U.preventDefault(), !!A) {
|
|
1394
|
+
E(null), q(!0);
|
|
1312
1395
|
try {
|
|
1313
|
-
const
|
|
1314
|
-
amount:
|
|
1315
|
-
card:
|
|
1316
|
-
customer:
|
|
1396
|
+
const M = {
|
|
1397
|
+
amount: y,
|
|
1398
|
+
card: v,
|
|
1399
|
+
customer: r,
|
|
1317
1400
|
description: o,
|
|
1318
|
-
metadata:
|
|
1319
|
-
idempotencyKey:
|
|
1320
|
-
},
|
|
1321
|
-
if (l &&
|
|
1322
|
-
const
|
|
1323
|
-
|
|
1401
|
+
metadata: i,
|
|
1402
|
+
idempotencyKey: Pt()
|
|
1403
|
+
}, T = await J.authorize(M);
|
|
1404
|
+
if (l && T.status === "authorized") {
|
|
1405
|
+
const x = await J.capture(T.id, y);
|
|
1406
|
+
m == null || m(x);
|
|
1324
1407
|
} else
|
|
1325
|
-
|
|
1326
|
-
} catch (
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1408
|
+
m == null || m(T);
|
|
1409
|
+
} catch (M) {
|
|
1410
|
+
const T = M instanceof Error ? M : new Error(String(M));
|
|
1411
|
+
E(T.message), b == null || b(T);
|
|
1329
1412
|
} finally {
|
|
1330
|
-
|
|
1413
|
+
q(!1);
|
|
1331
1414
|
}
|
|
1332
1415
|
}
|
|
1333
1416
|
},
|
|
1334
1417
|
[
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1418
|
+
A,
|
|
1419
|
+
y,
|
|
1420
|
+
v,
|
|
1421
|
+
r,
|
|
1339
1422
|
o,
|
|
1340
|
-
|
|
1423
|
+
i,
|
|
1341
1424
|
l,
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1425
|
+
J,
|
|
1426
|
+
m,
|
|
1427
|
+
b
|
|
1345
1428
|
]
|
|
1346
|
-
),
|
|
1429
|
+
), H = V(y.currency);
|
|
1347
1430
|
return /* @__PURE__ */ N(
|
|
1348
1431
|
"form",
|
|
1349
1432
|
{
|
|
1350
|
-
ref:
|
|
1433
|
+
ref: h,
|
|
1351
1434
|
className: "nice-payment-form" + (d ? ` ${d}` : ""),
|
|
1352
|
-
style:
|
|
1353
|
-
onSubmit:
|
|
1354
|
-
"aria-busy":
|
|
1435
|
+
style: f,
|
|
1436
|
+
onSubmit: oe,
|
|
1437
|
+
"aria-busy": R,
|
|
1355
1438
|
children: [
|
|
1356
|
-
/* @__PURE__ */
|
|
1357
|
-
|
|
1439
|
+
/* @__PURE__ */ s("div", { className: "nice-payment-form__amount", children: c ? /* @__PURE__ */ s(
|
|
1440
|
+
He,
|
|
1358
1441
|
{
|
|
1359
1442
|
label: "Amount",
|
|
1360
|
-
value:
|
|
1361
|
-
currency:
|
|
1443
|
+
value: y,
|
|
1444
|
+
currency: S,
|
|
1362
1445
|
currencies: a,
|
|
1363
|
-
onChange: (
|
|
1364
|
-
onCurrencyChange: (
|
|
1365
|
-
|
|
1446
|
+
onChange: (U) => U && _(U),
|
|
1447
|
+
onCurrencyChange: (U) => {
|
|
1448
|
+
g(U), _((M) => ({ ...M, currency: U }));
|
|
1366
1449
|
},
|
|
1367
|
-
disabled:
|
|
1450
|
+
disabled: R,
|
|
1368
1451
|
required: !0,
|
|
1369
1452
|
showFormattedPreview: !0
|
|
1370
1453
|
}
|
|
1371
1454
|
) : /* @__PURE__ */ N("div", { className: "nice-payment-form__total", children: [
|
|
1372
|
-
/* @__PURE__ */
|
|
1373
|
-
/* @__PURE__ */
|
|
1455
|
+
/* @__PURE__ */ s("span", { className: "nice-payment-form__total-label", children: "Total" }),
|
|
1456
|
+
/* @__PURE__ */ s(Fe, { value: y })
|
|
1374
1457
|
] }) }),
|
|
1375
|
-
o && /* @__PURE__ */
|
|
1376
|
-
/* @__PURE__ */
|
|
1377
|
-
|
|
1458
|
+
o && /* @__PURE__ */ s("p", { className: "nice-payment-form__description", children: o }),
|
|
1459
|
+
/* @__PURE__ */ s("div", { className: "nice-payment-form__card", children: /* @__PURE__ */ s(
|
|
1460
|
+
Rt,
|
|
1378
1461
|
{
|
|
1379
|
-
value:
|
|
1380
|
-
onChange: (
|
|
1381
|
-
|
|
1462
|
+
value: v,
|
|
1463
|
+
onChange: (U, M) => {
|
|
1464
|
+
O(U), Z(M);
|
|
1382
1465
|
},
|
|
1383
|
-
disabled:
|
|
1466
|
+
disabled: R
|
|
1384
1467
|
}
|
|
1385
1468
|
) }),
|
|
1386
|
-
!
|
|
1469
|
+
!z && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1387
1470
|
e.name,
|
|
1388
1471
|
" does not accept ",
|
|
1389
|
-
(
|
|
1472
|
+
(H == null ? void 0 : H.name) ?? y.currency,
|
|
1390
1473
|
"."
|
|
1391
1474
|
] }),
|
|
1392
|
-
!
|
|
1475
|
+
!P && X && /* @__PURE__ */ N("div", { className: "nice-payment-form__warning", role: "alert", children: [
|
|
1393
1476
|
"Minimum charge for ",
|
|
1394
1477
|
e.name,
|
|
1395
1478
|
" is ",
|
|
1396
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ s(Fe, { value: X }),
|
|
1397
1480
|
"."
|
|
1398
1481
|
] }),
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
/* @__PURE__ */
|
|
1482
|
+
p && /* @__PURE__ */ s("div", { className: "nice-payment-form__consents", children: p }),
|
|
1483
|
+
ne && /* @__PURE__ */ s("div", { className: "nice-payment-form__error", role: "alert", children: ne }),
|
|
1484
|
+
/* @__PURE__ */ s(
|
|
1402
1485
|
"button",
|
|
1403
1486
|
{
|
|
1404
1487
|
type: "submit",
|
|
1405
1488
|
className: "nice-payment-form__submit",
|
|
1406
|
-
disabled: !
|
|
1407
|
-
"aria-disabled": !
|
|
1408
|
-
children:
|
|
1489
|
+
disabled: !A,
|
|
1490
|
+
"aria-disabled": !A,
|
|
1491
|
+
children: R ? "Processing…" : u
|
|
1409
1492
|
}
|
|
1410
1493
|
),
|
|
1411
1494
|
/* @__PURE__ */ N("p", { className: "nice-payment-form__processor", children: [
|
|
1412
1495
|
"Secured by ",
|
|
1413
|
-
/* @__PURE__ */
|
|
1496
|
+
/* @__PURE__ */ s("strong", { children: e.name })
|
|
1414
1497
|
] })
|
|
1415
1498
|
]
|
|
1416
1499
|
}
|
|
1417
1500
|
);
|
|
1418
1501
|
}
|
|
1419
1502
|
);
|
|
1420
|
-
function
|
|
1503
|
+
function Pt() {
|
|
1421
1504
|
return typeof crypto < "u" && "randomUUID" in crypto ? crypto.randomUUID() : `idem_${Date.now().toString(36)}_${Math.random().toString(36).slice(2)}`;
|
|
1422
1505
|
}
|
|
1423
|
-
const
|
|
1506
|
+
const Xt = de(function({
|
|
1424
1507
|
price: e,
|
|
1425
1508
|
originalPrice: n,
|
|
1426
|
-
period:
|
|
1427
|
-
prefix:
|
|
1509
|
+
period: c,
|
|
1510
|
+
prefix: r,
|
|
1428
1511
|
suffix: a,
|
|
1429
1512
|
showDiscountBadge: o = !0,
|
|
1430
|
-
size:
|
|
1513
|
+
size: i = "md",
|
|
1431
1514
|
locale: l,
|
|
1432
|
-
className:
|
|
1433
|
-
style:
|
|
1434
|
-
},
|
|
1435
|
-
const
|
|
1436
|
-
return /* @__PURE__ */ N("div", { ref:
|
|
1437
|
-
|
|
1515
|
+
className: u,
|
|
1516
|
+
style: m
|
|
1517
|
+
}, b) {
|
|
1518
|
+
const p = n && n.currency === e.currency && n.amount > e.amount, d = k(() => !p || !n ? null : Math.round((n.amount - e.amount) / n.amount * 100), [p, n, e.amount]), f = `nice-price-tag nice-price-tag--${i}` + (u ? ` ${u}` : "");
|
|
1519
|
+
return /* @__PURE__ */ N("div", { ref: b, className: f, style: m, children: [
|
|
1520
|
+
r && /* @__PURE__ */ s("span", { className: "nice-price-tag__prefix", children: r }),
|
|
1438
1521
|
/* @__PURE__ */ N("span", { className: "nice-price-tag__main", children: [
|
|
1439
|
-
/* @__PURE__ */
|
|
1440
|
-
|
|
1522
|
+
/* @__PURE__ */ s("span", { className: "nice-price-tag__amount", children: te(e, { locale: l }) }),
|
|
1523
|
+
c && /* @__PURE__ */ s("span", { className: "nice-price-tag__period", children: c })
|
|
1441
1524
|
] }),
|
|
1442
|
-
|
|
1443
|
-
|
|
1525
|
+
p && n && /* @__PURE__ */ s("span", { className: "nice-price-tag__original", "aria-label": "Original price", children: /* @__PURE__ */ s("s", { children: te(n, { locale: l }) }) }),
|
|
1526
|
+
p && o && d != null && d > 0 && /* @__PURE__ */ N("span", { className: "nice-price-tag__discount", "aria-label": `${d} percent off`, children: [
|
|
1444
1527
|
"−",
|
|
1445
1528
|
d,
|
|
1446
1529
|
"%"
|
|
1447
1530
|
] }),
|
|
1448
|
-
a && /* @__PURE__ */
|
|
1531
|
+
a && /* @__PURE__ */ s("span", { className: "nice-price-tag__suffix", children: a })
|
|
1449
1532
|
] });
|
|
1450
|
-
}),
|
|
1533
|
+
}), Qt = de(
|
|
1451
1534
|
function({
|
|
1452
1535
|
source: e,
|
|
1453
1536
|
onSourceChange: n,
|
|
1454
|
-
targetCurrency:
|
|
1455
|
-
onTargetCurrencyChange:
|
|
1537
|
+
targetCurrency: c,
|
|
1538
|
+
onTargetCurrencyChange: r,
|
|
1456
1539
|
provider: a,
|
|
1457
1540
|
locale: o,
|
|
1458
|
-
showRateLine:
|
|
1541
|
+
showRateLine: i = !0,
|
|
1459
1542
|
className: l,
|
|
1460
|
-
style:
|
|
1461
|
-
},
|
|
1462
|
-
const { converted:
|
|
1543
|
+
style: u
|
|
1544
|
+
}, m) {
|
|
1545
|
+
const { converted: b, loading: p, error: d } = ve(e, c, a), f = k(
|
|
1463
1546
|
() => ({ amount: Math.pow(10, 2), currency: e.currency }),
|
|
1464
1547
|
[e.currency]
|
|
1465
|
-
), { converted:
|
|
1466
|
-
|
|
1467
|
-
|
|
1548
|
+
), { converted: h } = ve(
|
|
1549
|
+
i ? f : null,
|
|
1550
|
+
c,
|
|
1468
1551
|
a
|
|
1469
1552
|
);
|
|
1470
1553
|
return /* @__PURE__ */ N(
|
|
1471
1554
|
"div",
|
|
1472
1555
|
{
|
|
1473
|
-
ref:
|
|
1556
|
+
ref: m,
|
|
1474
1557
|
className: "nice-currency-converter" + (l ? ` ${l}` : ""),
|
|
1475
|
-
style:
|
|
1558
|
+
style: u,
|
|
1476
1559
|
children: [
|
|
1477
|
-
/* @__PURE__ */
|
|
1478
|
-
|
|
1560
|
+
/* @__PURE__ */ s("div", { className: "nice-currency-converter__row", children: /* @__PURE__ */ s(
|
|
1561
|
+
He,
|
|
1479
1562
|
{
|
|
1480
1563
|
label: "From",
|
|
1481
1564
|
value: e,
|
|
1482
|
-
onChange: (
|
|
1565
|
+
onChange: (y) => y && n(y),
|
|
1483
1566
|
currency: e.currency,
|
|
1484
|
-
onCurrencyChange: (
|
|
1567
|
+
onCurrencyChange: (y) => n({ ...e, currency: y }),
|
|
1485
1568
|
showFormattedPreview: !1
|
|
1486
1569
|
}
|
|
1487
1570
|
) }),
|
|
1488
1571
|
/* @__PURE__ */ N("div", { className: "nice-currency-converter__row", children: [
|
|
1489
|
-
/* @__PURE__ */
|
|
1572
|
+
/* @__PURE__ */ s("label", { className: "nice-currency-converter__label", children: "To" }),
|
|
1490
1573
|
/* @__PURE__ */ N("div", { className: "nice-currency-converter__output", children: [
|
|
1491
|
-
/* @__PURE__ */
|
|
1492
|
-
|
|
1574
|
+
/* @__PURE__ */ s(
|
|
1575
|
+
qe,
|
|
1493
1576
|
{
|
|
1494
|
-
value:
|
|
1495
|
-
onChange: (
|
|
1577
|
+
value: c,
|
|
1578
|
+
onChange: (y) => r(y),
|
|
1496
1579
|
compact: !0
|
|
1497
1580
|
}
|
|
1498
1581
|
),
|
|
1499
|
-
/* @__PURE__ */
|
|
1582
|
+
/* @__PURE__ */ s("span", { className: "nice-currency-converter__amount", children: p ? "…" : d ? "—" : b ? te(b, { locale: o }) : "" })
|
|
1500
1583
|
] })
|
|
1501
1584
|
] }),
|
|
1502
|
-
|
|
1585
|
+
i && h && /* @__PURE__ */ N("p", { className: "nice-currency-converter__rate", children: [
|
|
1503
1586
|
"1 ",
|
|
1504
1587
|
e.currency,
|
|
1505
1588
|
" = ",
|
|
1506
|
-
|
|
1589
|
+
te(h, { locale: o }),
|
|
1507
1590
|
" ",
|
|
1508
1591
|
/* @__PURE__ */ N("span", { className: "nice-currency-converter__inverse", children: [
|
|
1509
1592
|
"· 1 ",
|
|
1510
|
-
|
|
1593
|
+
c,
|
|
1511
1594
|
" =",
|
|
1512
1595
|
" ",
|
|
1513
|
-
|
|
1596
|
+
te(W(1 / Ke(h), e.currency), { locale: o })
|
|
1514
1597
|
] })
|
|
1515
1598
|
] }),
|
|
1516
|
-
d && /* @__PURE__ */
|
|
1599
|
+
d && /* @__PURE__ */ s("p", { className: "nice-currency-converter__error", role: "alert", children: d.message })
|
|
1600
|
+
]
|
|
1601
|
+
}
|
|
1602
|
+
);
|
|
1603
|
+
}
|
|
1604
|
+
);
|
|
1605
|
+
function Ae(t) {
|
|
1606
|
+
return { amount: Math.round(t.amount), currency: t.currency };
|
|
1607
|
+
}
|
|
1608
|
+
const Vt = de(
|
|
1609
|
+
function({
|
|
1610
|
+
lines: e,
|
|
1611
|
+
locale: n,
|
|
1612
|
+
rounding: c = "line",
|
|
1613
|
+
showTotals: r = !0,
|
|
1614
|
+
showGrandTotal: a = !0,
|
|
1615
|
+
hideRateColumn: o = !1,
|
|
1616
|
+
labels: i,
|
|
1617
|
+
density: l = "comfortable",
|
|
1618
|
+
className: u,
|
|
1619
|
+
style: m,
|
|
1620
|
+
id: b
|
|
1621
|
+
}, p) {
|
|
1622
|
+
const d = {
|
|
1623
|
+
label: (i == null ? void 0 : i.label) ?? "Item",
|
|
1624
|
+
rate: (i == null ? void 0 : i.rate) ?? "VAT",
|
|
1625
|
+
net: (i == null ? void 0 : i.net) ?? "Net",
|
|
1626
|
+
vat: (i == null ? void 0 : i.vat) ?? "Tax",
|
|
1627
|
+
gross: (i == null ? void 0 : i.gross) ?? "Gross",
|
|
1628
|
+
total: (i == null ? void 0 : i.total) ?? "Total"
|
|
1629
|
+
}, f = k(() => {
|
|
1630
|
+
if (c === "total") {
|
|
1631
|
+
const _ = /* @__PURE__ */ new Map();
|
|
1632
|
+
for (const g of e) {
|
|
1633
|
+
let v = _.get(g.vatRate);
|
|
1634
|
+
v || (v = [], _.set(g.vatRate, v)), v.push(g.netAmount);
|
|
1635
|
+
}
|
|
1636
|
+
const S = [];
|
|
1637
|
+
for (const [g, v] of _) {
|
|
1638
|
+
const O = v.reduce((R, q) => me(R, q), W(0, v[0].currency)), Y = Ae(De(O, g)), Z = me(O, Y);
|
|
1639
|
+
S.push({ rate: g, net: O, vat: Y, gross: Z });
|
|
1640
|
+
}
|
|
1641
|
+
return S;
|
|
1642
|
+
}
|
|
1643
|
+
return e.map((_) => {
|
|
1644
|
+
const S = Ae(De(_.netAmount, _.vatRate)), g = me(_.netAmount, S);
|
|
1645
|
+
return { label: _.label, rate: _.vatRate, net: _.netAmount, vat: S, gross: g };
|
|
1646
|
+
});
|
|
1647
|
+
}, [e, c]), h = k(() => {
|
|
1648
|
+
if (f.length === 0)
|
|
1649
|
+
return null;
|
|
1650
|
+
const _ = f[0].net.currency;
|
|
1651
|
+
let S = W(0, _), g = W(0, _), v = W(0, _);
|
|
1652
|
+
for (const O of f)
|
|
1653
|
+
S = me(S, O.net), g = me(g, O.vat), v = me(v, O.gross);
|
|
1654
|
+
return { net: S, vat: g, gross: v };
|
|
1655
|
+
}, [f]), y = (_) => te(_, { locale: n });
|
|
1656
|
+
return /* @__PURE__ */ N(
|
|
1657
|
+
"table",
|
|
1658
|
+
{
|
|
1659
|
+
ref: p,
|
|
1660
|
+
id: b,
|
|
1661
|
+
className: `nice-tax-breakdown nice-tax-breakdown--${l} ${u ?? ""}`,
|
|
1662
|
+
style: m,
|
|
1663
|
+
role: "table",
|
|
1664
|
+
"aria-label": d.total,
|
|
1665
|
+
children: [
|
|
1666
|
+
/* @__PURE__ */ s("thead", { children: /* @__PURE__ */ N("tr", { children: [
|
|
1667
|
+
f.some((_) => _.label !== void 0) && /* @__PURE__ */ s("th", { scope: "col", children: d.label }),
|
|
1668
|
+
!o && /* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__rate", children: d.rate }),
|
|
1669
|
+
/* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.net }),
|
|
1670
|
+
/* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.vat }),
|
|
1671
|
+
/* @__PURE__ */ s("th", { scope: "col", className: "nice-tax-breakdown__num", children: d.gross })
|
|
1672
|
+
] }) }),
|
|
1673
|
+
/* @__PURE__ */ s("tbody", { children: f.map((_, S) => /* @__PURE__ */ N("tr", { children: [
|
|
1674
|
+
f.some((g) => g.label !== void 0) && /* @__PURE__ */ s("td", { children: _.label ?? "" }),
|
|
1675
|
+
!o && /* @__PURE__ */ N("td", { className: "nice-tax-breakdown__rate", children: [
|
|
1676
|
+
(_.rate * 100).toLocaleString(n, { maximumFractionDigits: 2 }),
|
|
1677
|
+
"%"
|
|
1678
|
+
] }),
|
|
1679
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.net) }),
|
|
1680
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.vat) }),
|
|
1681
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(_.gross) })
|
|
1682
|
+
] }, `${_.rate}-${S}`)) }),
|
|
1683
|
+
r && h && /* @__PURE__ */ s("tfoot", { children: a && /* @__PURE__ */ N("tr", { className: "nice-tax-breakdown__totals", children: [
|
|
1684
|
+
f.some((_) => _.label !== void 0) && /* @__PURE__ */ s("td", { children: d.total }),
|
|
1685
|
+
!o && /* @__PURE__ */ s("td", {}),
|
|
1686
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.net) }),
|
|
1687
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.vat) }),
|
|
1688
|
+
/* @__PURE__ */ s("td", { className: "nice-tax-breakdown__num", children: y(h.gross) })
|
|
1689
|
+
] }) })
|
|
1517
1690
|
]
|
|
1518
1691
|
}
|
|
1519
1692
|
);
|
|
1520
1693
|
}
|
|
1521
1694
|
);
|
|
1522
1695
|
export {
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1696
|
+
lt as EcbRatesProvider,
|
|
1697
|
+
st as ExchangeRateHostProvider,
|
|
1698
|
+
at as FrankfurterProvider,
|
|
1699
|
+
ut as FreeForexApiProvider,
|
|
1700
|
+
mt as MockPaymentProcessor,
|
|
1701
|
+
fe as NICE_CURRENCY_CATALOG,
|
|
1702
|
+
Zt as NICE_CURRENCY_CODES,
|
|
1703
|
+
Gt as NICE_PAYMENT_PROCESSORS,
|
|
1704
|
+
ot as NbpRatesProvider,
|
|
1705
|
+
Rt as NiceCreditCardInput,
|
|
1706
|
+
Qt as NiceCurrencyConverter,
|
|
1707
|
+
qe as NiceCurrencySelector,
|
|
1708
|
+
Fe as NiceMoney,
|
|
1709
|
+
He as NiceMoneyInput,
|
|
1710
|
+
Jt as NicePaymentForm,
|
|
1711
|
+
Xt as NicePriceTag,
|
|
1712
|
+
Vt as NiceTaxBreakdown,
|
|
1713
|
+
it as OpenExchangeRatesProvider,
|
|
1714
|
+
Lt as StaticExchangeRateProvider,
|
|
1715
|
+
me as addMoney,
|
|
1716
|
+
At as compareMoney,
|
|
1717
|
+
dt as convertMoney,
|
|
1718
|
+
Ht as createEcbRatesProvider,
|
|
1719
|
+
zt as createFreeForexApiProvider,
|
|
1720
|
+
qt as createNbpRatesProvider,
|
|
1721
|
+
jt as createOpenExchangeRatesProvider,
|
|
1722
|
+
Ne as detectCardBrand,
|
|
1723
|
+
ye as expectedCvcLength,
|
|
1724
|
+
V as findCurrency,
|
|
1725
|
+
ct as formatCardNumber,
|
|
1726
|
+
te as formatMoney,
|
|
1727
|
+
Ke as fromMoney,
|
|
1728
|
+
Le as isExpiryValid,
|
|
1729
|
+
Kt as isNegative,
|
|
1730
|
+
Ot as isZero,
|
|
1731
|
+
Be as luhnCheck,
|
|
1732
|
+
ft as makeAdyenAdapter,
|
|
1733
|
+
vt as makeAutopayAdapter,
|
|
1734
|
+
Ct as makeBlikAdapter,
|
|
1735
|
+
_t as makeBraintreeAdapter,
|
|
1736
|
+
xt as makeCoinbaseCommerceAdapter,
|
|
1737
|
+
$t as makeKlarnaAdapter,
|
|
1738
|
+
bt as makeMollieAdapter,
|
|
1739
|
+
yt as makePayPalAdapter,
|
|
1740
|
+
gt as makePayUAdapter,
|
|
1741
|
+
wt as makePrzelewy24Adapter,
|
|
1742
|
+
Nt as makeRazorpayAdapter,
|
|
1743
|
+
ht as makeSquareAdapter,
|
|
1744
|
+
pt as makeStripeAdapter,
|
|
1745
|
+
Dt as makeTpayAdapter,
|
|
1746
|
+
Tt as maskCardNumber,
|
|
1747
|
+
De as multiplyMoney,
|
|
1748
|
+
Bt as negateMoney,
|
|
1749
|
+
Te as normaliseExpiry,
|
|
1750
|
+
rt as parseMoney,
|
|
1751
|
+
Et as registerCurrency,
|
|
1752
|
+
nt as subtractMoney,
|
|
1753
|
+
W as toMoney,
|
|
1754
|
+
ve as useNiceExchangeRate,
|
|
1755
|
+
Yt as useNiceMoney,
|
|
1756
|
+
St as useNicePayment,
|
|
1757
|
+
Ie as validateCreditCard
|
|
1574
1758
|
};
|